Show:

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 Function

    Function 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

Item Index

Methods

Methods

emit

(
  • type
  • data
)

Emit event if the condition is satisfied.

Parameters:

trigger

(
  • type
  • data
)

Alias of emit.

Parameters: