taskCallbackManager
Create an R-level task callback manager

Description

Controls a list of callback functions that can be called from any other function.

Usage

taskCallbackManager(handlers = list(), registered = FALSE, 
    verbose = FALSE)

Arguments

handlers a list of lists, each with a component "f", a logical-valued function of 4 or 5 arguments, and possibly a component "data", which is any sort of object. See addTaskCallback for the form of such functions.
registered a logical value. If TRUE, then set the internal registered flag so that subsequent calls to add do not register this callback manager with the top-level expression task callback system.
verbose a logical value that is currently ignored.
Value
returns a list of six functions.
addA function with the argument list function(f, data = NULL, name = NULL, register = TRUE), which adds the callback function f and possibly the object data and the name name to this callback manager's list of callback function. If register is TRUE, and if this callback manager has not already been registered with the top-level callback system (see addCallback), then the callback manager is registered so that all the functions in its callback list are run at the end of each top-level expression. f must return TRUE or FALSE. (FALSE means to remove it from the callback manager's list of callback functions.)
evaluateA function with the argument list function(expr, value, ok, visible) that calls each function on this callback manager's callback list with those arguments, and possibly the data argument stored along with the callback.
removeA function with the argument list function(which), where which should be either an integer position in the callback list or the name of an item in the callback list. This function returns TRUE if which actually refers to an item on the callback list (which means that item was removed) and FALSE otherwise.
registerA function with the argument list function(name = "R-taskCallbackManager", verbose = .verbose) that calls addTaskCallback(evaluate, name=name) so that all of the handler's callbacks are called after each top-level expression. Also, this function sets the internal registered flag so that subsequent calls to add do not cause the list to be evaluated again.
suspendA function with the argument list function(status = TRUE). This function sets an internal flag, which, if TRUE, causes evaluate to not evaluate the functions on the callback list, but without taking any callbacks off the list. suspend(FALSE) causes evaluate to resume normal behavior.
callbacksA function with the argument list function() that returns the list of callback entries. Each entry is a list with a component f, the callback function itself, and possibly (data), the optional object to pass to f each time it is called.
Note
taskCallbackManager provides a convenient way to control a group of callback functions.
See Also
addTaskCallback
Examples
## Not run: 
h <- taskCallbackManager(register=TRUE)
h$add(function(expr, result, ok, visible) { if (!visible) print(result); TRUE })
h$register(name = "Autoprint Everything")
invisible(5:1)
1/(1:5)
removeTaskCallback("Autoprint Everything")
invisible(sin(1:4))

## End(Not run)
Package base version 6.1.1-7
Package Index