mhfen / PubSub

A simple utility for creating a publish / subscribe object in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PubSub

A simple utility class for creating a publish / subscribe object in JavaScript. Based on the PubSub util David Walsh posted here. It is meant to be helpful in cross-module communication.

Usage

Via JavaScript

Instantiate a PubSub object, then publish and subscribe:

var newPubSub = new PubSub();

newPubSub.subscribe('aNewTopic', function() {
    // do things when aNewTopic is published to
});

newPubSub.publish('aNewTopic', {
    data: 'I want to publish this data to the topic.'
});

About

A simple utility for creating a publish / subscribe object in JavaScript

License:MIT License


Languages

Language:JavaScript 100.0%