event emitter of tree shape, offer pipe operation.
- event of tree shape
- trigger eventItem and trigger eventTree
- pipe operation
- support typescript
- doculment click here, welcome to star & issue!
yarn add event-emitter-tree
npm i event-emitter-tree
- use with esm
import {EventCore} from 'event-emitter-tree';
- use with commonjs
const {EventCore} = require('event-emitter-tree');
- the tree forked by a string
->
- take pe for an example, if you bind event
pe
,pe->basketball
,pe->basketball->shooting
,pe->football->defence
, then you can trigger one of them or a tree flexibly. - bind Event:
let core = new EventCore();
core.on('pe', fnPe);
core.on('pe->basketball', fnPeBasketball);
core.on('pe->basketball->shooting', fnPeBasketballShooting);
core.on('pe->football->defence', fnPeFootballDefence);
- the eventTree would be as follows:
{
pipe: pipePe,
tree: {
basketball: {
pipe: pipePeBasketball,
tree: {
shooting: {
pipe: pipePeBasketballShooting
}
}
},
football: {
tree: {
defence: {
pipe: pipePeFootballDefence
}
}
}
}
}
- you can trigger eventItem or eventTree
core.trigger('pe->basketball');
core.triggerTree('pe')