tapable

node v10.24.1
version: master
endpointsharetweet
const { SyncHook, SyncBailHook, SyncLoopHook, SyncWaterfallHook, AsyncParallelHook, AsyncParallelBailHook, AsyncSeriesHook, AsyncSeriesBailHook, AsyncSeriesWaterfallHook } = require('tapable') class TapableTest { constructor() { this.hooks = { sync: new SyncHook(['context', 'hi']), syncBail: new SyncBailHook(), syncLoop: new SyncLoopHook(), syncWaterfall: new SyncWaterfallHook(['syncwaterfall']), asyncParallel: new AsyncParallelHook(), asyncParallelBail: new AsyncParallelBailHook(), asyncSeries: new AsyncSeriesHook(), asyncSeriesBail: new AsyncSeriesBailHook(), asyncSeriesWaterfall: new AsyncSeriesWaterfallHook(['asyncwaterfall']) } } emitSync() { this.hooks.sync.call(this, err => { console.log(this.hooks.sync.promise) console.log(err) }) } emitAyncSeries() { this.hooks.asyncSeries.callAsync(err => { if (err) console.log(err) }) } } const test = new TapableTest() test.hooks.sync.tap('TestPlugin', (context, callback) => { console.log('trigger: ', context) callback(new Error('this is sync error')) }) test.hooks.asyncSeries.tapAsync('AsyncSeriesPlugin', callback => { callback(new Error('this is async series error')) }) test.emitSync() test.emitAyncSeries()
Loading…

no comments

    sign in to comment