Skip to content

Latest commit

 

History

History
81 lines (55 loc) · 2.66 KB

README.md

File metadata and controls

81 lines (55 loc) · 2.66 KB

Messenger

NPM version GitHub last commit Github workflow Test coverage npm bundle size License

Messenger is a tiny Javascript library to handle messages that carry a payload. It is designed to be embedded in another library. Messenger run on both Node.js and ECMAScript 2015 (ES6) compliant browsers.

Quick Startup

// Listens for an event:
mess.subscribe('mycustomevent', function(payload) {
  console.log('fired mycustomevent: ' + payload);
});

// Fires an event:
mess.publish('mycustomevent', 'this is the payload for mycustomevent');

API

Static methods

Messenger provides a set of static methods. You can use by typing:

Messenger.noConflict();
Static Methods Description
noConflict returns the Messenger variable to its previous owner,

Create a Messenger object:

Constructor Description
Messenger() creates the Messenger object that handles messages,

Methods

Methods Description
subscribe adds an event listener,
subscribeOnce adds an event listener that is fired once,
unsubscribe removes an event listener,
publish fires an event/message,

License

MIT.