Don't require session to be explicitly passed to invalidateLater

These functions were created before getDefaultReactiveDomain()
existed, so the only way to get ahold of the current session was
if the caller explicitly passed it.

This is slightly backwards incompatible, in that existing calls
to invalidateLater() that don't pass a session argument will
behave slightly differently (bound to the current session instead
of to no session), but those calls would have triggered a warning
for all but the very earliest versions of Shiny.
This commit is contained in:
Joe Cheng
2015-11-02 14:19:29 -08:00
parent ad28e03536
commit a767a61f43
4 changed files with 11 additions and 18 deletions

View File

@@ -4,7 +4,7 @@
\alias{invalidateLater}
\title{Scheduled Invalidation}
\usage{
invalidateLater(millis, session)
invalidateLater(millis, session = getDefaultReactiveDomain())
}
\arguments{
\item{millis}{Approximate milliseconds to wait before invalidating the
@@ -45,7 +45,7 @@ shinyServer(function(input, output, session) {
# input$n changes.
output$plot <- renderPlot({
# Re-execute this reactive expression after 2000 milliseconds
invalidateLater(2000, session)
invalidateLater(2000)
hist(isolate(input$n))
})
})

View File

@@ -4,7 +4,7 @@
\alias{reactiveTimer}
\title{Timer}
\usage{
reactiveTimer(intervalMs = 1000, session)
reactiveTimer(intervalMs = 1000, session = getDefaultReactiveDomain())
}
\arguments{
\item{intervalMs}{How often to fire, in milliseconds}
@@ -39,7 +39,7 @@ shinyServer(function(input, output, session) {
# Anything that calls autoInvalidate will automatically invalidate
# every 2 seconds.
autoInvalidate <- reactiveTimer(2000, session)
autoInvalidate <- reactiveTimer(2000)
observe({
# Invalidate and re-execute this reactive expression every time the