Show:

EventHandler extends EventEmitter to provide subscription methods. It also includes helper methods on the constructor for setting up Controllers and Views with input and output emitters.

Constructor

Events.EventHandler

()

Example:

 var eventHandlerA = new EventHandler();
         var eventHandlerB = new EventHandler();
        
         eventHandlerB.subscribe(eventHandlerA);
        
         eventHandlerB.on('name', function(payload){
             console.log(payload) // {data : 0}
         });
        
         eventHandlerA.emit('name', {data : 0});

Methods

bindThis

(
  • owner
)

Inherited from Events.EventEmitter:

A convenience method to bind the provided object to all added handlers.

Parameters:

  • owner Object

    Bound this context

emit

(
  • type
  • data
)

Inherited from Events.EventEmitter:

Broadcast an event on the type channel with an optional payload. This will call the handlers of all EventEmitters listening on the type channel with the (optional) data payload as its argument.

Parameters:

off

(
  • type
  • [handler]
)

Inherited from Events.EventEmitter but overwritten in

Removes the handler from the type channel. If a handler is not specified or if there are no remaining handlers of the type, the EventHandler removes itself from the upstream sources.

Parameters:

on

(
  • type
  • handler
)

Inherited from Events.EventEmitter but overwritten in

Adds a handler to the type channel which will be executed on emit. Extends EventEmitter's on method.

Parameters:

once

(
  • type
  • handler
)

Inherited from Events.EventEmitter:

Behaves like EventEmitter.prototype.on, except the handler is only executed once.

Parameters:

setInputHandler

(
  • object
  • handler
)
static

Constructor helper method. Assign an event handler to receive an object's input events. Defines trigger, subscribe and unsubscribe methods on the class instance.

Parameters:

  • object Object

    Class instance

  • handler EventHandler

    EventHandler representing an input source

setOutputHandler

(
  • object
  • handler
)
static

Constructor helper method. Assign an event handler to emit an object's output events. Defines emit, on and off methods on the class instance.

Parameters:

  • object Object

    Object to provide on, off and emit methods

  • handler EventHandler

    Handler assigned event handler

subscribe

(
  • source
)

Listen for events from an an upstream source.

Parameters:

  • source EventEmitter

    Event source

trigger

()

Inherited from Events.EventEmitter:

Alias for emit.

unsubscribe

(
  • [source]
)

Stop listening to events from an upstream source. Undoes work of subscribe.

If no source is provided, all subscribed sources are unsubscribed from.

Parameters:

  • [source] EventEmitter optional

    Event source