taskCallbackManager {base} | R Documentation |
This provides an entirely S-language mechanism for managing callbacks or actions that are invoked at the conclusion of each top-level task. Essentially, we register a single R function from this manager with the underlying, native task-callback mechanism and this function handles invoking the other R callbacks under the control of the manager. The manager consists of a collection of functions that access shared variables to manage the list of user-level callbacks.
taskCallbackManager(handlers = list(), registered = FALSE,
verbose = FALSE)
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 |
A list containing 6 functions:
add |
register a callback with this manager, giving the
function, an optional 5-th argument, an optional name
by which the callback is stored in the list,
and a |
remove |
remove an element from the manager's collection of callbacks, either by name or position/index. |
evaluate |
the ‘real’ callback function that is registered with the C-level dispatch mechanism and which invokes each of the R-level callbacks within this manager's control. |
suspend |
a function to set the suspend state
of the manager. If it is suspended, none of the callbacks will be
invoked when a task is completed. One sets the state by specifying
a logical value for the |
register |
a function to register the |
callbacks |
returns the list of callbacks being maintained by this manager. |
This is an experimental feature and the interface may be changed in the future.
addTaskCallback
,
removeTaskCallback
,
getTaskCallbackNames
\
http://developer.r-project.org/TaskHandlers.pdf
# create the manager
h <- taskCallbackManager()
# add a callback
h$add(function(expr, value, ok, visible) {
cat("In handler\n")
return(TRUE)
}, name = "simpleHandler")
# look at the internal callbacks.
getTaskCallbackNames()
# look at the R-level callbacks
names(h$callbacks())
getTaskCallbackNames()
removeTaskCallback("R-taskCallbackManager")