A helper function that safely increments a Shiny progress bar only when the Shiny app is running and within a reactive context.
Details
This function checks whether the Shiny application is running and whether there is a valid reactive domain before calling `shiny::incProgress()`. It prevents errors when the progress bar is used outside of a reactive environment or during testing/non-interactive use.
Examples
if (FALSE) { # \dontrun{
withProgress(message = "Loading...", {
for (i in 1:10) {
safe_inc_progress(0.1)
Sys.sleep(0.1)
}
})
} # }
