pec-core-promievent
v1.0.5
Published
This package extends the EventEmitter with the Promise class to allow chaining as well as multiple final states of a function.
Downloads
9
Readme
pec-core-promievent
[![NPM Package][npm-image]][npm-url] [![Dependency Status][deps-image]][deps-url] [![Dev Dependency Status][deps-dev-image]][deps-dev-url]
This is a sub-package of [pec.js][repo].
This is the PromiEvent package used to return a EventEmitter mixed with a Promise to allow multiple final states as well as chaining.
Please read the [documentation][docs] for more.
Installation
Node.js
npm install pec-core-promievent
Usage
const Web3PromiEvent = require('pec-core-promievent');
const myFunc = function(){
const promiEvent = Web3PromiEvent();
setTimeout(function() {
promiEvent.eventEmitter.emit('done', 'Hello!');
promiEvent.resolve('Hello!');
}, 10);
return promiEvent.eventEmitter;
};
// and run it
myFunc()
.on('done', console.log)
.then(console.log);