| AsyncProgress {ipc} | R Documentation |
A progress bar object where inc and set are usable within other processes
Description
A progress bar object where inc and set are usable within other processes
A progress bar object where inc and set are usable within other processes
Details
An async compatible wrapper around Shiny's progress bar. It should be instatiated from the main process, but may be closed, set and incremented from any process.
Methods
Public methods
Method new()
Creates a new progress panel and displays it.
Usage
AsyncProgress$new( ..., queue = shinyQueue(), millis = 250, value = NULL, message = NULL, detail = NULL )
Arguments
...Additional parameters to be passed to Shiny::Progress
queueA Queue object for message passing
millisHow often in milliseconds should updates to the progress bar be checked for.
valueA numeric value at which to set the progress bar, relative to
minandmax.messageA single-element character vector; the message to be displayed to the user, or
NULLto hide the current message (if any).detailA single-element character vector; the detail message to be displayed to the user, or
NULLto hide the current detail message (if any). The detail message will be shown with a de-emphasized appearance relative tomessage.
Method getMax()
Returns the maximum
Usage
AsyncProgress$getMax()
Method getMin()
Returns the minimum
Usage
AsyncProgress$getMin()
Method sequentialClose()
Removes the progress panel and destroys the queue. Must be called from main process.
Usage
AsyncProgress$sequentialClose()
Method set()
Updates the progress panel. When called the first time, the progress panel is displayed.
Usage
AsyncProgress$set(value = NULL, message = NULL, detail = NULL)
Arguments
valueA numeric value at which to set
messageA single-element character vector; the message to be displayed to the user, or
NULLto hide the current message (if any).detailA single-element character vector; the detail message to be displayed to the user, or
NULLto hide the current detail message (if any). The detail message will be shown with a de-emphasized appearance relative tomessage.
Method inc()
Like set, this updates the progress panel. The difference is
that inc increases the progress bar by amount, instead
of setting it to a specific value.
Usage
AsyncProgress$inc(amount = 0.1, message = NULL, detail = NULL)
Arguments
amountthe size of the increment.
messageA single-element character vector; the message to be displayed to the user, or
NULLto hide the current message (if any).detailA single-element character vector; the detail message to be displayed to the user, or
NULLto hide the current detail message (if any). The detail message will be shown with a de-emphasized appearance relative tomessage.
Method close()
Fires a close signal and may be used from any process.
Usage
AsyncProgress$close()
Method clone()
The objects of this class are cloneable with this method.
Usage
AsyncProgress$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## Only run examples in interactive R sessions
if (interactive()) {
library(shiny)
library(future)
plan(multisession)
ui <- fluidPage(
actionButton("run","Run"),
tableOutput("dataset")
)
server <- function(input, output, session) {
dat <- reactiveVal()
observeEvent(input$run, {
progress <- AsyncProgress$new(session, min=1, max=15)
future({
for (i in 1:15) {
progress$set(value = i)
Sys.sleep(0.5)
}
progress$close()
cars
}) %...>% dat
NULL #return something other than the future so the UI is not blocked
})
output$dataset <- renderTable({
req(dat())
})
}
shinyApp(ui, server)
}