Nitrogen Poisonous Monoxide
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@mobilabs/messenger

1.0.0 • Public • Published

Messenger

NPM version GitHub last commit Travis CI Test coverage Dependencies status Dev Dependencies status 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.

Install

npm i @mobilabs/messenger

DownloadsWeekly Downloads

19

Version

1.0.0

License

MIT

Unpacked Size

45.8 kB

Total Files

10

Last publish

Collaborators

  • avatar