addHook(hook)
Adds a hook.
Hook is added to the end of the list. See getHooks method and hooks in plugins.
Arguments
hook(Hook): An object witheventandhandlerproperties. See plugins for more info.
Throws
If
eventis not a string, it will throw an errorHook's event must be a string.If
eventdoesn't begin withpreorpost, it will throw an errorHook's event must start with 'pre' or 'post'.If
handleris not a function, it will throw an errorHook's handler must be a function.
Example
// assuming that you already have cache instance prepared
const hook = {
event: 'preGetItem',
handler: () => { ... } // some function that does something, not relevant here
}
cache.addHook(hook);Last updated