registerCommandStreamCallback | R Documentation |
Registers a callback to be executed whenever any RStudio command is invoked.
registerCommandStreamCallback(callback)
callback |
A function to execute when the command is invoked. |
The callback function will be given a single argument with the ID of the command that was invoked. See the RStudio Server Professional Administration Guide appendix for a list of command IDs.
Note that there is a small performance penalty incurred across the IDE when
a command stream listener is present. If you only need to listen to a few
specific commands, it is recommended to set up callbacks for them individually
using registerCommandCallback
.
A handle representing the registration. Pass this handle
to unregisterCommandCallback
to unregister the callback.
The registerCommandStreamCallback
function was introduced in RStudio 1.4.1589.
unregisterCommandCallback
to unregister the callback, and
registerCommandCallback
to be notified whenever a specific command
is executed.
## Not run:
# Set up a callback to print the ID of commands executed to the console.
handle <- rstudioapi::registerCommandStreamCallback(function(id) {
message("Command executed: ", id)
})
# Later: Unregister the callback
rstudioapi::unregisterCommandCallback(handle)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.