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
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
andmax
.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 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
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 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
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 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
deep
Whether 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)
}