Registers a (sync) callback to be called before each hook is being called.
hookable.beforeEach((event) => { console.log(`${event.name} hook is being called with ${event.args}`);});hookable.hook("test", () => { console.log("running test hook");});// test hook is being called with []// running test hookawait hookable.callHook("test");
afterEach (syncCallback)
Registers a (sync) callback to be called after each hook is being called.
hookable.afterEach((event) => { console.log(`${event.name} hook called with ${event.args}`);});hookable.hook("test", () => { console.log("running test hook");});// running test hook// test hook called with []await hookable.callHook("test");
createDebugger
Automatically logs each hook that is called and how long it takes to run.
Type checking improved. You can use Hookable<T> or createHooks<T>() to provide types interface (c2e1e22)
We no longer provide an IE11 compatible umd build. Instead, you should use an ESM-aware bundler such as webpack or rollup to transpile if needed.
Logger param is dropped. We use console.warn by default for deprecated hooks.
Package now uses named exports. You should import { Hookable } instead of Hookable or use new createHooks util
mergeHooks util is exported standalone. You should replace Hookable.mergeHooks and this.mergeHooks with new { mergeHooks } export
In versions < 5.0.0 when using callHook if an error happened by one of the hook callbacks, we was handling errors globally and call global error hook + console.error instead and resolve callHook promise! This sometimes makes confusing behavior when we think code worked but it didn't. v5 introduced a breaking change that when a hook throws an error, callHook also rejects instead of a global error event. This means you should be careful to handle all errors when using callHook now.