Skip to content

🔧 event emitter of tree shape, offer pipe operation.

License

Notifications You must be signed in to change notification settings

pomelott/event-emitter-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

event-emitter-tree

event emitter of tree shape, offer pipe operation.

Feature

  • event of tree shape
  • trigger eventItem and trigger eventTree
  • pipe operation
  • support typescript

Doc

Install

  yarn add event-emitter-tree
  npm i event-emitter-tree

Use

  • use with esm
  import {EventCore} from 'event-emitter-tree';
  • use with commonjs
  const {EventCore} = require('event-emitter-tree');

Description

  • 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')

About

🔧 event emitter of tree shape, offer pipe operation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published