mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-29 03:00:45 -04:00
Merge pull request #2523 from rstudio/joe/feature/readable-outputs
Support reading of Shiny outputs
This commit is contained in:
14
R/shiny.R
14
R/shiny.R
@@ -1087,6 +1087,9 @@ ShinySession <- R6Class(
|
||||
# will be attached to the observer after it's created.
|
||||
outputAttrs <- attr(func, "outputAttrs", TRUE)
|
||||
|
||||
# Save this for getOutput purposes
|
||||
outputAttrs$renderFunc <- func
|
||||
|
||||
funcFormals <- formals(func)
|
||||
# ..stacktraceon matches with the top-level ..stacktraceoff.., because
|
||||
# the observer we set up below has ..stacktraceon=FALSE
|
||||
@@ -1194,6 +1197,9 @@ ShinySession <- R6Class(
|
||||
stop(paste("Unexpected", class(func), "output for", name))
|
||||
}
|
||||
},
|
||||
getOutput = function(name) {
|
||||
attr(private$.outputs[[name]], "renderFunc", exact = TRUE)
|
||||
},
|
||||
flushOutput = function() {
|
||||
if (private$busyCount > 0)
|
||||
return()
|
||||
@@ -2093,7 +2099,13 @@ ShinySession <- R6Class(
|
||||
|
||||
#' @export
|
||||
`$.shinyoutput` <- function(x, name) {
|
||||
stop("Reading objects from shinyoutput object not allowed.")
|
||||
name <- .subset2(x, 'ns')(name)
|
||||
|
||||
if (getOption("shiny.allowoutputreads", FALSE)) {
|
||||
.subset2(x, 'impl')$getOutput(name)
|
||||
} else {
|
||||
stop("Reading from shinyoutput object is not allowed.")
|
||||
}
|
||||
}
|
||||
|
||||
#' @export
|
||||
|
||||
Reference in New Issue
Block a user