@mobilabs/messenger

1.0.4 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i @mobilabs/messenger

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

44.8 kB

Total Files

9

Last publish

Collaborators

  • jclo