Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more arguments for customization of session logic. #607

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

LTLA
Copy link
Member

@LTLA LTLA commented Nov 2, 2022

For example, we can do this to force the Shiny app to close once the user has disconnected:

example(iSEE, ask=FALSE) # create an example
iSEE(sce, customizeSession=function(session) session$onSessionEnded(stopApp))

This is useful for terminating R instances on some custom single-user Shiny deployments, e.g., based on Slurm or cloud services. Other possible uses involve activity logging once a user has finished.

As customizeSession() is run inside the server function, you can even stick your own custom logic in there:

library(shinyalert)

iSEE(sce, customizeSession=function(session) {
     stuff <- new.env()
     stuff$fired <- NA 
     observe({
           invalidateLater(10000, session=session)
           if (is.na(stuff$fired)) {
               stuff$fired <- FALSE # skip first firing
          } else if (!stuff$fired) {
                  shinyalert("FIRING SOME EVENT!")
                  stuff$fired <- TRUE
           }
     }, domain=session)
})

This is a much-simplified version of a timeout alert to alert the user when their session is about to expire.

@kevinrue
Copy link
Member

kevinrue commented Dec 5, 2022

Finally got around to checking this.

Looks nice.

What's the story about customTags? This PR seems to add in in the man page, but without adding it to the function definition nor the R code. Testing me? ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants