Ini menyediakan mekanisme bahasa S sepenuhnya untuk mengelola callback atau tindakan yang dipanggil pada akhir setiap tugas tingkat atas. Pada dasarnya, kami mendaftarkan satu fungsi R dari manajer ini dengan mekanisme panggilan balik tugas asli yang mendasarinya dan fungsi ini menangani pemanggilan panggilan balik R lainnya di bawah kendali manajer. Manajer terdiri dari kumpulan fungsi yang mengakses variabel bersama untuk mengelola daftar callback tingkat pengguna.
taskCallbackManager(handlers = list(), registered = FALSE,
verbose = FALSE)
| Parameter | Deskripsi |
|---|---|
handlers |
this can be a list of callbacks in which each element is a list with an element named "f" which is a callback function, and an optional element named "data" which is the 5-th argument to be supplied to the callback when it is invoked. Typically this argument is not specified, and one uses add to register callbacks after the manager is created. |
registered |
a logical value indicating whether the evaluate function has already been registered with the internal task callback mechanism. This is usually FALSE and the first time a callback is added via the add function, the evaluate function is automatically registered. One can control when the function is registered by specifying TRUE for this argument and calling addTaskCallback manually. |
verbose |
a logical value, which if TRUE, causes information to be printed to the console about certain activities this dispatch manager performs. This is useful for debugging callbacks and the handler itself. |
# NOT RUN {
# 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())
removeTaskCallback("R-taskCallbackManager")
# }