Events.EventMapper Class
Defined in:
samsara/events/EventMapper.js:6
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
FunctionFunction 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