How to use session$onSessionEnded to kill the app with flexdashboard shiny app

Hello,

I would like to use session$onSessionEnded(stopApp) inside a shiny application made with flexdashboard (https://rmarkdown.rstudio.com/flexdashboard/shiny.html)

The problem is that according to:


the code should go inside the server function but in a flexdashboard shiny app there is not a server function.

How can I make it work for a shiny app made with flexdashboard?

I believe the session is made available automatically, so you can do something like:

I added the code below at the bottom of the shiny app that I made with flexdashboard but it does not stop the app when the browser is closed

session$onSessionEnded(stopApp)

Are you running the document from RStudio (if so, please report the version) or the R console (if not, does the app stop from the R console)?

I am using Rstudio server Version 1.2.1327

R version 3.5.2 (2018-12-20)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

when I added the following code

session$onSessionEnded(stopApp)

The shiny flexdashboard was often disconnecting from the server and showing this message:
function () { .callbacks$remove(id) } <environment: 0xac847c0>

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.