SyncHook

简单示例

  1. const { SyncHook } = require('tapable');
  2. const hook = new SyncHook(['name', 'age']);
  3. hook.tap('1', (name, age) => {
  4. console.log('1===>', name, age);
  5. });
  6. hook.tap('2', (name, age) => {
  7. console.log('2===>', name, age);
  8. });
  9. hook.tap('3', (name, age) => {
  10. console.log('3===>', name, age);
  11. });
  12. hook.call('zce', 100);
  1. 1===> zce 100
  2. 2===> zce 100
  3. 3===> zce 100