Show:

EventMapper modifies the data payload of an event based on a provided function.

Note: it does not modify the event's type.

Constructor

Events.EventMapper

(
  • map
)

Parameters:

  • map Function

    Function to modify the event payload

Example:

 var eventMapper = new EventMapper(function(payload){
             return payload.x + payload.y
         });
        
         var eventEmitter = new EventEmitter();
        
         eventMapper.subscribe(eventEmitter);
        
         eventMapper.on('name', function(value){
             alert(value);
         });
        
         eventEmitter.emit('name', {x : 1, y : 2}); // alerts 3

Item Index

Methods

Methods

emit

(
  • type
  • data
)

Emit mapped event.

Parameters:

trigger

(
  • type
  • data
)

Alias of emit.

Parameters: