spinWhile: Run work while a map spinner is visible (Shiny)

View source: R/spin.R

spinWhileR Documentation

Run work while a map spinner is visible (Shiny)

Description

Starts the spinner, waits until the browser has painted it (and Shiny has flushed that update), then evaluates expr and always stops the spinner.

Usage

spinWhile(
  mapId,
  expr,
  options = NULL,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

mapId

The outputId of the leafletOutput.

expr

Expression to evaluate after the spinner is shown.

options

Passed to startSpinner.

session

The Shiny session; default is the current domain.

Value

The Shiny session (invisible).

See Also

Other Spinner Functions: addSpinner()

Examples

## Not run: 
observeEvent(input$go, {
  spinWhile("leaf", {
    Sys.sleep(2)
    leafletProxy("leaf") %>% addMarkers(data = quakes, ~long, ~lat)
  })
})

## End(Not run)

leaflet.extras2 documentation built on Sept. 10, 2026, 1:11 a.m.