EVOLUTION-MANAGER
Edit File: onStop.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Run code after an application or session ends</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for onStop {shiny}"><tr><td>onStop {shiny}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Run code after an application or session ends</h2> <h3>Description</h3> <p>This function registers callback functions that are invoked when the application exits (when <code><a href="runApp.html">runApp()</a></code> exits), or after each user session ends (when a client disconnects). </p> <h3>Usage</h3> <pre> onStop(fun, session = getDefaultReactiveDomain()) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>fun</code></td> <td> <p>A function that will be called after the app has finished running.</p> </td></tr> <tr valign="top"><td><code>session</code></td> <td> <p>A scope for when the callback will run. If <code>onStop</code> is called from within the server function, this will default to the current session, and the callback will be invoked when the current session ends. If <code>onStop</code> is called outside a server function, then the callback will be invoked with the application exits. If <code>NULL</code>, it is the same as calling <code>onStop</code> outside of the server function, and the callback will be invoked when the application exits.</p> </td></tr> </table> <h3>Value</h3> <p>A function which, if invoked, will cancel the callback. </p> <h3>See Also</h3> <p><code><a href="onFlush.html">onSessionEnded()</a></code> for the same functionality, but at the session level only. </p> <h3>Examples</h3> <pre> ## Only run this example in interactive R sessions if (interactive()) { # Open this application in multiple browsers, then close the browsers. shinyApp( ui = basicPage("onStop demo"), server = function(input, output, session) { onStop(function() cat("Session stopped\n")) }, onStart = function() { cat("Doing application setup\n") onStop(function() { cat("Doing application cleanup\n") }) } ) } # In the example above, onStop() is called inside of onStart(). This is # the pattern that should be used when creating a shinyApp() object from # a function, or at the console. If instead you are writing an app.R which # will be invoked with runApp(), you can do it that way, or put the onStop() # before the shinyApp() call, as shown below. ## Not run: # ==== app.R ==== cat("Doing application setup\n") onStop(function() { cat("Doing application cleanup\n") }) shinyApp( ui = basicPage("onStop demo"), server = function(input, output, session) { onStop(function() cat("Session stopped\n")) } ) # ==== end app.R ==== # Similarly, if you have a global.R, you can call onStop() from there. # ==== global.R ==== cat("Doing application setup\n") onStop(function() { cat("Doing application cleanup\n") }) # ==== end global.R ==== ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>shiny</em> version 1.5.0 <a href="00Index.html">Index</a>]</div> </body></html>