0.1.3 • Published 8 years ago

universalevents v0.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Universal Events

Event emitter for node and browser, based on EventEmitter but with extra features

Usage Example

import UniversalEvents from 'UniversalEvents';
var ue = new UniversalEvents();

// attach a function that is called when the matching event happens
ue.on('myEventName', function (data) {
    console.log('The data is: ' + data);
});
ue.raiseEvent('myEventName', 3); // logs "The data is: 3"
ue.raiseEvent('myEventName', 'hello') // logs "The data is: hello"

// create a Promise that is resolved on success and rejected on failure
ue.await('successEventName', 'failureEventName')
    .then(function (data) {
        console.log('Succeeded with: ' + data);
    })
ue.raiseEvent('successEventName', 5); // logs "Succeeded with: 5"
ue.await('successEventName', 'failureEventName')
    .catch(function (err) {
        console.log('Failed with: ' + err);
    });
ue.raiseEvent('failureEventName', new Error("fail")); // logs "Failed with: Error: fail"
0.1.3

8 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago