jmessenger
v0.0.3
Published
A tiny Javascript library to handle messages that carry a payload
Downloads
5
Readme
JMessenger
| JMessenger
is no longer maintained. Please, use @mobilabs/messenger now. |
| --- |
JMessenger
is a tiny Javascript library to handle messages that carry a payload. It is designed to be embedded in another library.
Quick Startup
// Creates the messenger object:
var mess = Messenger('mycustomevent');
// Listens for an event:
mess.on('mycustomevent', function(payload) {
console.log('fired mycustomevent: ' + payload);
});
// Fires an event:
mess.fire('mycustomevent', 'this is the payload for mycustomevent');
API
Static methods
JMessenger provides a set of static methods. You can use by typing:
JMessenger.noConflict();
| Static Methods | Description | |:---------------------|:------------| | noConflict | returns the JMessenger variable to its previous owner, |
Create a JMessenger object:
| Constructor | Description | |:------------|:------------| | JMessenger('messagename') | creates the JMessenger object that handles 'messagename' messages, |
Methods
| Methods | Description | |:--------------------|:------------| | addEvents | adds events/messages, | | addEventListener | adds an event listener, | | removeEventListener | removes an event listener, | | fire | fires an event/message, | | on | alias on addEventListener, | | off | alias on removeEventListener, | | trigger | alias on fire, |
License
MIT.