susyweb-core-promievent
v1.0.0-beta.35
Published
This package extends eventEmitters with promises to allow chaining as well as multiple final states of a function.
Downloads
4
Readme
susyweb-core-promievent
This is a sub package of susyweb.js
This is the PromiEvent package is used to return a EventEmitter mixed with a Promise to allow multiple final states as well as chaining. Please read the documentation for more.
Installation
Node.js
npm install susyweb-core-promievent
In the Browser
Build running the following in the susyweb.js repository:
npm run-script build-all
Then include dist/susyweb-core-promievent.js
in your html file.
This will expose the SusyWebPromiEvent
object on the window object.
Usage
// in node.js
var SusyWebPromiEvent = require('susyweb-core-promievent');
var myFunc = function(){
var promiEvent = SusyWebPromiEvent();
setTimeout(function() {
promiEvent.eventEmitter.emit('done', 'Hello!');
promiEvent.resolve('Hello!');
}, 10);
return promiEvent.eventEmitter;
};
// and run it
myFunc()
.then(console.log);
.on('done', console.log);