You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bloated with helper functions (can me mitigated with lenses)
gets more bloated for more then two events
Solution 2
waitFor::Int->Eventt()->Eventt()
waitFor n event =
mapAccumMaybe_ accFunc 0 event
where
accFunc x y =let z = x + y in (Just z, if z == n thenJust()elseNothing)
-- use it like this
waitFor 2$ mergeWith (+)$fmap ($>1) events
Disadvantages:
Doesn't actually solve the stated problem, when one of the events in the list can fire more then once
The text was updated successfully, but these errors were encountered:
rubenmoor
changed the title
How to fire an event on the condition that a couple of other events have fires at least once?
How to fire an event on the condition that a couple of other events have fired at least once?
Mar 2, 2023
Let's say my website is waiting for two web requests:
evRequest1Done :: Event t ()
andevRequest2Done :: Event t ()
Now I want an event
that fires once all events in the list have fired at least once.
What is the best way to go about this?
I can offer two solutions, both with drawbacks:
Solution 1
EDIT: record instead of sumtype with
Semigroup
instanceDisadvantages:
Once
requiredSolution 2
Disadvantages:
The text was updated successfully, but these errors were encountered: