Eventchain
- Eventchain is a module to call the callbacks on same event one after one.
- Just like the series feature in async module, but it's powered by node built-in module "EventEmitter".
- For better code structure, more maintainable.
install
npm install eventchain
Usage
var Eventchain = ; var ec = Eventchain; // if do not declare a name, it will create a run-once eventchain with a random name. // eg: var ec-only-once = Eventchain.create(); ec; ec; ec; // emit, should be given two arguments. // the first is an args which will pass to the first event in the chain. // the second is the top callback, which will handle error if event pass back to it, or fire after all the events executed. ec; // if ec is done and no useful any more. remember to clear it. // run-once eventchain will clear itself automatically. ecclear;
more detail, please see the example files.