Events.EventFilter Class
Defined in:
samsara/events/EventFilter.js:14
EventFilter regulates the broadcasting of events based on
a specified condition prescribed by a provided function
with the signature (data) -> Boolean
Constructor
Events.EventFilter
(
-
filter
Parameters:
-
filter
FunctionFunction returning a Boolean
Example:
var eventFilter = new EventFilter(function(payload){
return (payload.value == 0);
});
var eventEmitter = new EventEmitter();
eventFilter.subscribe(eventEmitter);
eventFilter.on('click', function(data){
alert('fired');
});
eventEmitter.emit('click', {value : 0}); // fired
eventEmitter.emit('click', {value : 1}); // doesn't fire