1.0.0-beta.35 • Published 5 years ago

susyweb-core-promievent v1.0.0-beta.35

Weekly downloads
1
License
LGPL-3.0
Repository
-
Last release
5 years ago

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);