Module: lib/pubsub

An Open Source PubSub Implementation
Version:
  • 1.4.0
Source:
See:
Example
// create a function to receive messages
var mySubscriber = function( msg, data ){
	console.log( msg, data );
};

require(['lib/pubsub'], function(createPublisher){
	// create a publisher using the factory method
	var publisher = createPublisher();

	// add the function to the list of subscribers for a particular message
	var subscription = publisher.subscribe( 'MY MESSAGE', mySubscriber );

	// publish a message asyncronously
	publisher.publish( 'MY MESSAGE', 'hello world!' );
	// logs 'MY MESSAGE', 'hello world!' to the console

	// unsubscribe from further messages
	subscription.dispose();
});

Classes

createPublisher
Publisher