Can I access to session values from onStop / onSessionEnded functions?
onStop(function() {
cat(file = stderr(), paste(app, session$clientData$url_protocol, sep = ' - '))
})
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.
You'll have to use isolate
to access reactiveValues
(such as session
) in a non reactive context :
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With