EVOLUTION-MANAGER
Edit File: invalidateLater.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Scheduled Invalidation</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for invalidateLater {shiny}"><tr><td>invalidateLater {shiny}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Scheduled Invalidation</h2> <h3>Description</h3> <p>Schedules the current reactive context to be invalidated in the given number of milliseconds. </p> <h3>Usage</h3> <pre> invalidateLater(millis, session = getDefaultReactiveDomain()) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>millis</code></td> <td> <p>Approximate milliseconds to wait before invalidating the current reactive context.</p> </td></tr> <tr valign="top"><td><code>session</code></td> <td> <p>A session object. This is needed to cancel any scheduled invalidations after a user has ended the session. If <code>NULL</code>, then this invalidation will not be tied to any session, and so it will still occur.</p> </td></tr> </table> <h3>Details</h3> <p>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 <code>invalidateLater</code> from being run. </p> <h3>See Also</h3> <p><code><a href="reactiveTimer.html">reactiveTimer()</a></code> is a slightly less safe alternative. </p> <h3>Examples</h3> <pre> ## Only run examples in interactive R sessions if (interactive()) { ui <- fluidPage( sliderInput("n", "Number of observations", 2, 1000, 500), plotOutput("plot") ) server <- 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) hist(rnorm(isolate(input$n))) }) } shinyApp(ui, server) } </pre> <hr /><div style="text-align: center;">[Package <em>shiny</em> version 1.5.0 <a href="00Index.html">Index</a>]</div> </body></html>