svTaskCallbackManager {svKomodo} | R Documentation |
Create task callbacks that are evaluated both from R and socket/http server
Description
svTaskCallbackManager()
is a copy of taskCallbackManager()
in R base
package, as of version 4.0.5 of R. Two important differences: (1) the top
task created is named SV-taskCallbackManager
instead of
R-taskCallbackManager
, and its tasks are executed after each top-level task
in R console, or after execution of non-hidden R code from the socket or http
server (take care: only once per set of code, no matter the number of
top-level task in the R code send by the client in the second case). All
taskCallbacks defined by addTaskCallback()
or taskCallbackManager$add()
from R base package are not executed when code is invoked from the R socket
or http server!
Usage
svTaskCallbackManager(handlers = list(), registered = FALSE, verbose = FALSE)
Arguments
handlers |
this can be a list of callbacks in which each element is a
list with an element named |
registered |
a logical value indicating whether the |
verbose |
a logical value, which if |
Value
See ?taskCallbackManager
for both the returned object and how to use it.
Author(s)
Slightly modified from the original R core team's function by Ph. Grosjean phgrosjean@sciviews.org
See Also
Examples
# create a task callback manager
cbman <- svTaskCallbackManager()
# Add a function to activate after each code evaluation in R
cbman$add(function(expr, value, ok, visible) {
cat("Hi from the callback manager!\n")
return(TRUE)
}, name = "exampleHandler")
# Just issue a command and see the callback function activated
1 + 1
# List defined callbacks
cbman$callbacks()
# Remove the callback we just defined
cbman$remove("exampleHandler")
1 + 1
# Remove the task callback manager (base R function)
removeTaskCallback("SV-taskCallbackManager")