Skip to content

robbie-c/universalevents

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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"

About

ES6 events for node and browsers, based of EventEmitter but with extra features.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published