opp-tapable
v1.0.0-alpha.53
Published
Small optimization for [Tapable](https://github.com/webpack/tapable) hooks.
Downloads
645
Readme
opp-core
Small optimization for Tapable hooks.
Installation
Using npm:
$ npm install --save opp-tapable
TapableHook (After Optimization)
Return Callable Function
import { SyncHook } from 'opp-tapale';
const hook = new SyncHook(['name']);
hook.tap('log', console.log);
hook('xiaoshuang'); // ✅
import { SyncHook } from 'tapale';
const hook = new SyncHook(['name']);
hook.tap('log', console.log);
hook.call('xiaoshuang'); // 🅾️
Support Revoke Callback
import { SyncHook } from 'opp-tapale';
const hook = new SyncHook(['name']);
const revoke = hook.tap('log', console.log);
hook('xiaoshuang'); // log 'xiaoshuang'
revoke();
// hook.revoke(console.log);
hook('xiaoshuang'); // log nothing