withProgress {tabler}R Documentation

Run a Long Computation with a Progress Overlay

Description

Shows the full-page progress overlay (see showProgress), then runs expr, then hides the overlay again - but unlike calling showProgress/hideProgress directly around a blocking computation, expr is deferred with later2::later() so that tablerApp's event loop gets a chance to actually flush the "show" message to the browser before the slow work begins.

Usage

withProgress(session = getDefaultReactiveDomain(), text = "Loading...", expr)

Arguments

session The session object passed by tablerApp to the server function. Defaults to getDefaultReactiveDomain().
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 withProgress() itself has already returned.

See Also

showProgress, tablerApp

Examples

if (interactive()) {
  ui <- page(
    title = "Progress Example",
    body = body(actionButton("btn", "Load data"))
  )

  server <- function(input, output, session) {
    observeEvent(input$btn, {
      withProgress(session, "Loading data...", {
        Sys.sleep(2)
      })
    })
  }

  tablerApp(ui, server)
}

Loading...