-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An interesting Applicative
-ish way of combining Event
s
#245
Comments
@ChrisPenner observed on Twitter that this is basically https://www.learnrxjs.io/learn-rxjs/operators/combination/combinelatest from RxJS. Fun! |
Opinion: on balance I think I am in favor of including cool types like this in As a counterpoint, though, look how sprawling the The challenge of course is to decide where to draw the line, and indeed the line may be at "no additional types beyond |
I'm afraid the Perhaps onDone <- combineLatest do
beforePick <- latest aoiBeforePick.onImageAcquired
... I like the idea though. Looks handy for implementing various drag-n-drops (: |
Another option for types like this and |
Hola,
I just found this fairly interesting little
newtype
:The idea is we can use
Applicative
to combine events by zipping new event occurences with previous occurences for other events.Here's an example of it in use:
Here we see no event is emitted for the first two frames, because we haven't yet seen an occurance of the
Right
event. As soon as that happens (frame 3) we're able to return a triple of: the last seenLeft
event, the pure!
character, and the latestRight
event. The applicative then continues to "hold" previous values for all events as new events come in.This is especially nice when we want an event to fire when multiple events have occured, as we can now use
ApplicativeDo
:Here I want to build up a
PNPResult
structure by holding various events. If these wereBehavior
s it would be easier, but that's not what I'm producing. I wanted a way to build theEvent
applicatively, and this seems to be the magic solution! Thanks to #220, this is now possible.If this is deemed useful, we could always add it in to
reactive-banana
itself.The text was updated successfully, but these errors were encountered: