| with_progress {tabler} | R Documentation |
Run a Long Computation with a Progress Overlay
Description
Shows the full-page progress overlay (see show_progress),
then runs expr, then hides the overlay again - but unlike calling
show_progress/hide_progress directly around a
blocking computation, expr is deferred with later2::later()
so that tabler_app's event loop gets a chance to actually
flush the "show" message to the browser before the slow work begins.
Usage
with_progress(session = get_default_reactive_domain(), text = "Loading...", expr)
Arguments
session |
The session object passed by tabler_app
to the server function. Defaults to get_default_reactive_domain().
|
text |
The message displayed above the progress bar. |
expr |
The (potentially slow) expression to run once the overlay is visible. |
Value
Invisibly, NULL. expr runs asynchronously, after
with_progress() itself has already returned.
See Also
show_progress, tabler_app
Examples
if (interactive()) {
ui <- page(
title = "Progress Example",
body = body(action_button("btn", "Load data"))
)
server <- function(input, output, session) {
observe_event(input$btn, {
with_progress(session, "Loading data...", {
Sys.sleep(2)
})
})
}
tabler_app(ui, server)
}