AsyncProgress | R Documentation |
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
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.
new()
Creates a new progress panel and displays it.
AsyncProgress$new( ..., queue = shinyQueue(), millis = 250, value = NULL, message = NULL, detail = NULL )
...
Additional parameters to be passed to Shiny::Progress
queue
A Queue object for message passing
millis
How often in milliseconds should updates to the progress bar be checked for.
value
A numeric value at which to set
the progress bar, relative to min
and max
.
message
A single-element character vector; the message to be
displayed to the user, or NULL
to hide the current message
(if any).
detail
A single-element character vector; the detail message
to be displayed to the user, or NULL
to hide the current
detail message (if any). The detail message will be shown with a
de-emphasized appearance relative to message
.
getMax()
Returns the maximum
AsyncProgress$getMax()
getMin()
Returns the minimum
AsyncProgress$getMin()
sequentialClose()
Removes the progress panel and destroys the queue. Must be called from main process.
AsyncProgress$sequentialClose()
set()
Updates the progress panel. When called the first time, the progress panel is displayed.
AsyncProgress$set(value = NULL, message = NULL, detail = NULL)
value
A numeric value at which to set
message
A single-element character vector; the message to be
displayed to the user, or NULL
to hide the current message
(if any).
detail
A single-element character vector; the detail message
to be displayed to the user, or NULL
to hide the current
detail message (if any). The detail message will be shown with a
de-emphasized appearance relative to message
.
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.
AsyncProgress$inc(amount = 0.1, message = NULL, detail = NULL)
amount
the size of the increment.
message
A single-element character vector; the message to be
displayed to the user, or NULL
to hide the current message
(if any).
detail
A single-element character vector; the detail message
to be displayed to the user, or NULL
to hide the current
detail message (if any). The detail message will be shown with a
de-emphasized appearance relative to message
.
close()
Fires a close signal and may be used from any process.
AsyncProgress$close()
clone()
The objects of this class are cloneable with this method.
AsyncProgress$clone(deep = FALSE)
deep
Whether to make a deep clone.
## 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) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.