Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including jmessenger with all npm packages installed. Try it out:

var jmessenger = require("jmessenger")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

jmessenger v0.0.3

A tiny Javascript library to handle messages that carry a payload

JMessenger

NPM version Travis CI Test coverage Dependencies status Dev Dependencies status License

[![NPM install][npm-install-image]][npm-install-url]
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 MethodsDescription
noConflictreturns the JMessenger variable to its previous owner,

Create a JMessenger object:

ConstructorDescription
JMessenger('messagename')creates the JMessenger object that handles 'messagename' messages,

Methods

MethodsDescription
addEventsadds events/messages,
addEventListeneradds an event listener,
removeEventListenerremoves an event listener,
firefires an event/message,
onalias on addEventListener,
offalias on removeEventListener,
triggeralias on fire,

License

MIT.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free