Allow for isolate calls to have no context and input name changes to have no context

This commit is contained in:
Barret Schloerke
2018-05-02 15:11:58 -04:00
parent 8648737a7a
commit 5ae2d5a24b
2 changed files with 13 additions and 6 deletions

View File

@@ -346,7 +346,7 @@ MessageLogger = R6Class(
depth = 0L,
display = TRUE,
messages = c(),
reactCache = list(),
reactCache = list("rNoCtx" = list(label = "<UNKNOWN>", reactId = "<UNKNOWN>")),
option = "shiny.reactlog",
initialize = function(display, depth, option) {

View File

@@ -36,9 +36,12 @@ Dependents <- R6Class(
# at times, the context is run in a ctx$onInvalidate(...) which has no runtime context
invalidate = function(log = TRUE) {
if (isTRUE(log)) {
ctx = getCurrentContext()
rLog$invalidateStart(.reactId, ctx$id, ctx$.reactType, ctx$.domain)
on.exit(rLog$invalidateEnd(.reactId, ctx$id, ctx$.reactType, ctx$.domain), add = TRUE)
# when new keys are added to input, there is no context
if (hasCurrentContext()) {
ctx <- getCurrentContext()
rLog$invalidateStart(.reactId, ctx$id, ctx$.reactType, ctx$.domain)
on.exit(rLog$invalidateEnd(.reactId, ctx$id, ctx$.reactType, ctx$.domain), add = TRUE)
}
}
lapply(
.dependents$values(),
@@ -1877,8 +1880,12 @@ reactiveFileReader <- function(intervalMillis, session, filePath, readFunc, ...)
#' # input object, like input$x
#' @export
isolate <- function(expr) {
curCtx <- getCurrentContext()
ctx <- Context$new(getDefaultReactiveDomain(), '[isolate]', type='isolate', reactId = curCtx$.reactId)
if (hasCurrentContext()) {
reactId <- getCurrentContext()$.reactId
} else {
reactId <- "rNoCtx"
}
ctx <- Context$new(getDefaultReactiveDomain(), '[isolate]', type='isolate', reactId = reactId)
on.exit(ctx$invalidate())
# Matching ..stacktraceon../..stacktraceoff.. pair
..stacktraceoff..(ctx$run(function() {