getHook(hookName) setHook(hookName, value, action = c("append", "prepend", "replace")) packageEvent(pkgname, event = c("onLoad", "attach", "detach", "onUnload"))
hookName | a character string specifying the hook name. Usually, it is the result returned by packageEvent. |
value | a hook function or NULL. |
action | a character string specifying the action. Must be one of "append", "prepend", or "replace". Partial matching is accepted. |
pkgname | a character string specifying the name of package or namespace associated with given event. |
event | a character string specifying the event that a package or a namespace associates. Must be one of "onLoad", "attach", "detach" or "onUnload". Partial matching is accepted. |
getHook | returns a function or a list of functions of the hook specified by hookName, or it returns an empty list if the hook does not exist. |
setHook | returns nothing. |
packageEvent | returns a character string representing the hook name. |
packageEvent("package1_test_abc", "onLoad") # "UserHook::package1::onLoad" packageEvent("package2.test.abc", "at") # "UserHook::package2.test.abc::attach"setHook(packageEvent("ff", "onLoad"), function(...) base::options(ffbatchbytes = 16095641, ffmaxbytes = 804782080)) # set a new hook getHook(packageEvent("ff", "onLoad"))
setHook(packageEvent("ff", "onLoad"), function(...) base::options(ff_foo = TRUE), action = "prepend") # prepend a hook to above one. getHook(packageEvent("ff", "onLoad"))
setHook(packageEvent("ff", "onLoad"), NULL, action = "replace") # remove the hook getHook(packageEvent("ff", "onLoad"))