Skip to content
Channeled event library
JavaScript CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Eventworks is a channeled pub sub system.

Basic features:

  • Channel support.
  • Chainable interface, you always get the channel object back from Eventworks calls.
  • Private instances allow you to add a new Eventworks within your modules.

Similarly named events belonging to different modules are put on their own channels:

var module1Channel ='module1');
module1Channel.subscribe('update', function(info) {
  console.log('Update module 1 ' + info);
module1Channel.publish('update', 'info to pass');

var module2Channel ='module2');
module1Channel.subscribe('update', function(info) {
  console.log('update module 2 ' + info);
module2Channel.publish('update', 'info to pass');


//Global default channel object.;

//Can call methods directly on Eventworks, will default to global channel.
Eventworks.subscribe ==;
Eventworks.publish ==;
Eventworks.unsubscribe ==;

//Named channel object. channelName);

var channel =;

//Subscription callbacks can recieve an argument when called
channel.subscribe(string topicName, function callback);
//They can also be called with a context
channel.subscribe(string topicName, function callback, object context);

//Publish just an event or with an argument for the callback
channel.publish(string topicName);
channel.publish(string topicName, object eventObject);

//Unsubscribe with varying amounts of specificity.
//Removes all subscriptions that match inputs.
channel.unsubscribe(string topicName);
channel.unsubscribe(string topicName, function callback);
channel.unsubscribe(string topicName, function callback, object context);

//Interface is chainable.
channel.subscribe('topic', callback).publish('topic').unsubscribe('topic', callback);

//Make a new instance of Eventworks
var newEventworks = Eventworks.makeEventworks();

//Mixin a new instance of Eventworks to an object
//Adds channel, publish, subscribe, unsubscribe methods
//that reference their own new internals

//All of this is a wholly separate Eventworks instance.
var internalChannel ='internalChannel');
internalChannel.subscribe('internalTopic', someCallback)

internalChannel !=='internalChannel');
You can’t perform that action at this time.