Can’t seem to find the signature for filterBy, is it just “filterBy( function(event state) -> true | false )”???
Also, is it possible to filter by Event Type?
Instead of me writing:
when( {
eventA :
eventB
eventC
})
I want to write something like:
when( {
$any:
}).filterBy( eventType != eventZ )
Thanks.
filterBy transforms your state not the incoming events, the pattern
match handles this.
You possibly don’t want to use filterBy.
What you probably want to do is have a projection that captures all event types using $any and then filter them out using a function
function filterByEventType(eventType){
return eventType == “foo” || eventType == “bar”;
}
fromAll()
.when({
$any:function(s,e){
if(filterByEventType(e.eventType)){
//do something
}
}
})
``