Can I access to session values from onStop / onSessionEnded functions?
onStop(function() {
cat(file = stderr(), paste(app, session$clientData$url_protocol, sep = ' - '))
})
Run Code Online (Sandbox Code Playgroud)
That code gives me this error: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context.
There is a way to get session values inside this functions?
If not, there is a way to execute a function just before the session is ended?
Thanks.
您必须在非反应性上下文中使用isolate来访问reactiveValues(例如session):
library(shiny)
ui <- fluidPage(
"Just close app after launch"
)
server <- function(input, output, session) {
onStop(fun = function() {
str(isolate(session$clientData$url_protocol))
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)