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

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

/@garfish/hooks/

    Package Sidebar

    Install

    npm i @garfish/hooks

    Weekly Downloads

    1,198

    Version

    1.19.1

    License

    MIT

    Unpacked Size

    19.2 kB

    Total Files

    6

    Last publish

    Collaborators

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