@garfish/hooks
v1.19.3
Published
hooks module.
Downloads
4,673
Readme
@garfish/hooks
Usage
import { AsyncHook, PluginSystem } from '@garfish/hooks';
const hooks = new PluginSystem({
a: new AsyncHook(),
});
hooks.usePlugin({
async a(a, b) {
console.log(a, b);
},
});
hooks.lifecycle.a.emit(1, 2);
Inherit parent hooks.
import { AsyncHook, PluginSystem } from '@garfish/hooks';
const hooks1 = new PluginSystem({
a: new AsyncHook(),
});
const hooks2 = new PluginSystem({
b: new AsyncHook(),
});
hooks2.inherit(hooks1);
hooks2.lifecycle.a.emit();