-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Streams with 'EventStream.fromFuture' drops result of futures if timing overlaps. #125
Comments
so what happens is this:
Though I don't know why you see the first |
It doesn't emit at all (as I would expect) in Laminar 17: https://scribble.ninja/u/yurique/czrgiiejskkirkcpqdfgzsznkwkn |
What Yurique said. The As for the solution, if your parent stream was something bounded, with a small number events in its lifetime, you could use flatMapMerge. But if it's really In principle we could have some version of a flatMap operator that works like I guess, in the absence of a proper completion feature, we could add some optional params to the flatMapMerge method, that would indicate when to stop listening to previous inner streams, e.g. after N events, after M seconds, etc. That would be kinda ugly, ad-hoc, and not an intuitive solution for this issue. A proper completion system would be better, but it's rather non-trivial to design, given Airstream semantics. |
Thanks for the explanations =) I will try |
@roman-mibex-2 Coolio, I just want to emphasize that the potential problem I had in mind is not so much the need for backpressure, it's that the futures won't be garbage-collected until the If your |
PS: flatMapMerge does work as expected =). Its good enough for now. Hmm, yes, it will leak memory. I think for most places we use it this will be OK, as page refreshes etc will clear the memory eventually. Otherwise we'll have to think of a way to feed js.Promises/Futures into a stream in some other way. And in other places dropping the events with |
Combining streams with
EventStream.fromFuture
behaves very unexpected to me when it starts to overlap.Lets say I've a EventStream (example stream of a searches) and I create a future for each event (like a fetch to a backend) and the use
.flatMap
to get the results as a stream, I get very unexpected behavior.When the futures complete before the next event is triggered, everything runs as expected:
Then I get this a new event for each completion of a future, as expected.
However, as soon as the future takes more time, the future results are dropped in the stream!
Now I get the first event, but all follow up events are dropped! (Or buffered somewhere?)
I still expect the stream events to arrive, but the do not arrive anymore. The 'late' events are dropped.
I would expect that each future completion still results in a event.
Are my expectations wrong?
How do I get all future completions in the stream?
The text was updated successfully, but these errors were encountered: