@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.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.41latest
0.0.4-beta.10beta

Version History

VersionDownloads (Last 7 Days)Published
1.0.41
1.0.30
1.0.20
1.0.10
1.0.00
0.0.70
0.0.60
0.0.50
0.0.41
0.0.4-beta.10
0.0.30
0.0.20
0.0.10
0.0.00

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