| taskCallbackManager {base} | R Documentation |
Create an R-level Task Callback Manager
Description
This provides an entirelyR-language mechanismfor managing callbacks or actions that are invoked atthe conclusion of each top-level task. Essentially,we register a singleR function from this managerwith the underlying, nativetask-callback mechanism and this function handles invoking the otherR callbacks under the control of the manager.The manager consists of a collection of functions that access sharedvariables to manage the list of user-level callbacks.
Usage
taskCallbackManager(handlers = list(), registered = FALSE, verbose = FALSE)Arguments
handlers | this can be a list of callbacks in which each elementis a list with an element named |
registered | a logical value indicating whetherthe |
verbose | a logical value, which if |
Value
Alist containing 6 functions:
add() | register a callback with this manager, giving thefunction, an optional 5-th argument, an optional nameby which the callback is stored in the list,and a |
remove() | remove an element from the manager's collectionof callbacks, either by name or position/index. |
evaluate() | the ‘real’ callback function that is registeredwith the C-level dispatch mechanism and which invokes each of theR-level callbacks within this manager's control. |
suspend() | a function to set the suspend stateof the manager. If it is suspended, none of the callbacks will beinvoked when a task is completed. One sets the state by specifyinga logical value for the |
register() | a function to register the |
callbacks() | returns the list of callbacks being maintainedby this manager. |
References
Temple Lang D (2001).“Top-level Task Callbacks in R.”https://developer.r-project.org/TaskHandlers.pdf.
See Also
addTaskCallback,removeTaskCallback,getTaskCallbackNames and the reference.
Examples
# create the managerh <- taskCallbackManager()# add a callbackh$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 callbacksnames(h$callbacks())removeTaskCallback("R-taskCallbackManager")