I am trying to introduce and synchronize a progress bar in an R Shiny app. This is a chunk from the main server function:
# Simulation Logic
observeEvent(input$calc_tax_prop_Button, {
progress <- shiny::Progress$new()
on.exit(progress$close())
progress$set(message = "Running Simulation", detail = "Please wait...", value = 0)
# Continuous back-and-forth movement of progress bar
for (i in 1:10) {
for (j in seq(0, 1, by = 0.1)) {
progress$set(value = j)
Sys.sleep(0.1)
}
for (j in seq(1, 0, by = -0.1)) {
progress$set(value = j)
Sys.sleep(0.1)
}
}
# Actual script execution
source("./Scripts/Scenarios.R") # ←- Other script to execute
showNotification("Simulation is done!", duration = NULL)
})
When I press the button which activates this code, I face a problem. Namely, I can see the progress indicator as shown below, but the issue is that the part for calling other scripts (source(“./Scripts/Scenarios.R”)) is not activated.
To summarize, the progress bar goes back and forth but is not connected with the activation of this line: source(“./Scripts/Scenarios.R”).
Namely, when I press the button which activates this code, I want to see the progress indicator moving back and forth until this line (source(“./Scripts/Scenarios.R”)) finishes executing. At the end, I want to see the notification showNotification(“Simulation is done!”, duration = NULL).
Can anybody please help me solve this problem?