Add callbacks for Shiny session events — onFlush

v1.7.4|Source: R/shiny.R


These functions are for registering callbacks on Shiny session events. onFlush registers a function that will be called before Shiny flushes the reactive system. onFlushed registers a function that will be called after Shiny flushes the reactive system. onSessionEnded registers a function to be called after the client has disconnected.

onFlush(fun, once = TRUE, session = getDefaultReactiveDomain())

onFlushed(fun, once = TRUE, session = getDefaultReactiveDomain())

onSessionEnded(fun, session = getDefaultReactiveDomain())



A callback function.


Should the function be run once, and then cleared, or should it re-run each time the event occurs. (Only for onFlush and onFlushed.)


A shiny session object.


These functions should be called within the application's server function.

All of these functions return a function which can be called with no arguments to cancel the registration.

See also

onStop() for registering callbacks that will be invoked when the application exits, or when a session ends.