Suppose I have an event trigger which I want to do two things when fired. First, I want it to update the value of some behavior. Second, if other conditions are met, I want it to fire another event send_off with the updated value of the behavior. Expressed in code form, suppose I have
trigger :: Event b
trigger = ...
updateFromTrigger :: b -> (a -> a)
updateFromTrigger = ...
conditionFromTrigger :: b -> Bool
conditionFromTrigger = ...
behavior :: Behavior a
behavior = accumB initial_value (updateFromTrigger <$> trigger)
send_off :: Event a
send_off = ?????? (filterE conditionFromTrigger trigger)
Then the question is: what do I put in the ?????? so that send_off sends the most up to date value of behavior, by which I mean that the value which includes the update from trigger that was just applied to it.
Unfortunately, if I understand correctly, the semantics of Behavior are such that the updated value isn't immediately available to me, so my only option here is essentially to duplicate the work and recompute the updated value of behavior so that I can use it immediately in another event, i.e. to fill in the ?????? with something like
send_off =
flip updateFromTrigger
<$>
behavior
<@>
filterE conditionFromTrigger trigger
Now, there is a sense in which I can make the updated information in the behavior available to me right away by using a Discrete instead of a Behavior, but really this is just equivalent to giving me an event that is fired simultaneously with my original event with the updated value, and unless I have missed something reactive-banana doesn't give me a way to fire an event only when two other events have fired simultaneously; that is, it provides unions of events but not intersections.
So I have two questions. First, is my understanding of this situation correct, and in particular am I correct in conclusion that my solution above is the only way to work around it? Second, purely out of curiosity, have there been any thoughts or plans by the developers on how to deal with intersections of events?