Chaplin.EventBroker → Source

The EventBroker offers an interface to interact with Chaplin.mediator, meant to be used as a mixin.


publishEvent(event, arguments...)

Publishes event globablly, passing arguments along for interested subscribers.

subscribeEvent(event, handler)

Subscribes the handler to the given event. If handler already subscribed to event, it will be removed as a subscriber and added afresh. This function is like Chaplin.mediator.subscribe except it cannot subscribe twice.

unsubscribeEvent(event, handler)

Unsubcribe the handler from the event. This functions like Chaplin.mediator.unsubscribe.


Unsubcribe from any subscriptions made through this objects subscribeEvent method.


To give a class these pub/sub capabilities, you just need to make it extend Chaplin.EventBroker: _.extend @prototype, EventBroker _.extend(this.prototype, EventBroker).