invalidateLater

0th

Percentile

Scheduled Invalidation

Schedules the current reactive context to be invalidated in the given number of milliseconds.

Usage
invalidateLater(millis, session)
Details

If this is placed within an observer or reactive expression, that object will be invalidated (and re-execute) after the interval has passed. The re-execution will reset the invalidation flag, so in a typical use case, the object will keep re-executing and waiting for the specified interval. It's possible to stop this cycle by adding conditional logic that prevents the invalidateLater from being run.

See Also

reactiveTimer is a slightly less safe alternative.

Aliases
Examples
shinyServer(function(input, output, session) {

  observe({
    # Re-execute this reactive expression after 1000 milliseconds
    invalidateLater(1000, session)

    # Do something each time this is invalidated.
    # The isolate() makes this observer _not_ get invalidated and re-executed
    # when input$n changes.
    print(paste("The value of input$n is", isolate(input$n)))
  })

  # Generate a new histogram at timed intervals, but not when
  # input$n changes.
  output$plot <- renderPlot({
    # Re-execute this reactive expression after 2000 milliseconds
    invalidateLater(2000, session)
    hist(isolate(input$n))
  })
})
Documentation reproduced from package shiny, version 0.9.1, License: GPL-3

Community examples

Looks like there are no examples yet.