shiny
shiny copied to clipboard
When the withProgress is closed, the program still runs in the background.
When the withProgress is closed, the program still runs in the background. I don't know if it's a bug, if not can add this feature? this is a example in 《Mastering Shiny》.
library(shiny)
ui <- fluidPage(
numericInput("steps", "How many steps?", 10),
actionButton("go", "go"),
textOutput("result")
)
server <- function(input, output, session) {
data <- eventReactive(input$go, {
withProgress(message = "Computing random number", {
for (i in seq_len(input$steps)) {
Sys.sleep(0.5)
incProgress(1 / input$steps)
}
runif(1)
})
})
output$result <- renderText(round(data(), 2))
}
shinyApp(ui, server)
Thanks!
the program still runs in the background.
I'm not sure I understand what you're referring to here. The example appears to work as expected for me. Could you please be more precise about what you're observing and how you expect it to be different?
I think @bioinformzhang is wanting the task/process to be cancelled when the progress message is closed.
Yep, when I close the progress bar(message) in the lower right corner, the program is still running in the background, as shown in the example 0.85
https://github.com/rstudio/shiny/assets/114212003/0e4afb42-6c3c-444d-ae24-b79422d33cfc