Fix #2037: With enableBookmarking="url", clientData is not available when observers are first run

Also fixed reactiveTimer firing even while async tasks are active
This commit is contained in:
Joe Cheng
2018-04-25 10:54:00 -07:00
parent c2f03aa833
commit 9dd4302fe9
3 changed files with 37 additions and 11 deletions

View File

@@ -1401,12 +1401,15 @@ reactiveTimer <- function(intervalMs=1000, session = getDefaultReactiveDomain())
}
timerHandle <<- scheduleTask(intervalMs, sys.function())
lapply(
dependents$values(),
function(dep.ctx) {
dep.ctx$invalidate()
NULL
})
session$cycleStartAction(function() {
lapply(
dependents$values(),
function(dep.ctx) {
dep.ctx$invalidate()
NULL
})
})
})
if (!is.null(session)) {

View File

@@ -279,7 +279,19 @@ createAppHandlers <- function(httpHandlers, serverFuncSource) {
shinysession$setShowcase(mode)
}
shinysession$manageInputs(msg$data)
# In shinysession$createBookmarkObservers() above, observers may be
# created, which puts the shiny session in busyCount > 0 state. That
# prevents the manageInputs here from taking immediate effect, by
# default. The manageInputs here needs to take effect though, because
# otherwise the bookmark observers won't find the clientData they are
# looking for. So use `now = TRUE` to force the changes to be
# immediate.
#
# FIXME: break createBookmarkObservers into two separate steps, one
# before and one after manageInputs, and put the observer creation
# in the latter. Then add an assertion that busyCount == 0L when
# this manageInputs is called.
shinysession$manageInputs(msg$data, now = TRUE)
# The client tells us what singletons were rendered into
# the initial page

View File

@@ -1863,10 +1863,16 @@ ShinySession <- R6Class(
}
}
},
# Set the normal and client data input variables
manageInputs = function(data) {
# Set the normal and client data input variables. Normally, managing
# inputs doesn't take immediate effect when there are observers that
# are pending execution or currently executing (including having
# started async operations that have yielded control, but not yet
# completed). The `now` argument can force this. It should generally
# not be used, but we're adding it to get around a show-stopping bug
# for Shiny v1.1 (see the call site for more details).
manageInputs = function(data, now = FALSE) {
force(data)
self$cycleStartAction(function() {
doManageInputs <- function() {
private$inputReceivedCallbacks$invoke(data)
data_names <- names(data)
@@ -1884,7 +1890,12 @@ ShinySession <- R6Class(
private$.clientData$mset(input_clientdata)
self$manageHiddenOutputs()
})
}
if (isTRUE(now)) {
doManageInputs()
} else {
self$cycleStartAction(doManageInputs)
}
},
outputOptions = function(name, ...) {
# If no name supplied, return the list of options for all outputs