Skip to content

crishushu/message-bus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

message-bus

UMD PubSub Implementation

Documentation

This package provides a framework-agnostic PubSub implementation and contains the following API:

Register a listener

register(eventName, functionHandler, executionContext)

Check for the existence of a registered listener object

isAlreadyRegistered(listener)

Remove a listener by event name

remove(eventName)

Trigger handler via event name

fire(eventName)

Getting Started

Install the module with: npm install message-bus

Registration of a listener:
var messageBus = require('message-bus');

var users = [];

function User (arg) {
    // some constructor code here
}

messageBus.register('login', function(credentials){
    this.push(new User(credentials))
}, users);
Trigger the handler of the listener at some other place in your code:
function login(credentials) {
    messageBus.fire('login', credentials);
}

License

Copyright (c) 2014 Christian H. Schulz
Licensed under the MIT license.

About

UMD PubSub Implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages