@garfish/hooks
TypeScript icon, indicating that this package has built-in type declarations

1.18.0 • Public • Published

@garfish/hooks

NPM version

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();

Readme

Keywords

Package Sidebar

Install

npm i @garfish/hooks

Weekly Downloads

799

Version

1.18.0

License

MIT

Unpacked Size

19.2 kB

Total Files

6

Last publish

Collaborators

  • reothues
  • aishiguang
  • cttrevor
  • shawzhou
  • jiadi0801
  • jsongo
  • rustle
  • zengkp