haxetink / tink_streams

Streams from the future. With lasers, of course ... whoaaaaa!!!!
The Unlicense
12 stars 9 forks source link

Add blend() #12

Closed kevinresol closed 7 years ago

kevinresol commented 7 years ago

So it is neither prepend nor append, but "mixture" of two streams.

back2dos commented 7 years ago

Hmm. I'm thinking about multiple things.

  1. What's the TailedStream really about? How does it differ from a compound stream? Streams are lazy by default, so Lazy<Stream<...>> seems a little overkill. And even if you want to be absolutely explicit about lazyness, then I think I would prefer a LazyStream<...> that wraps the Lazy<Stream<...>> and then you can go head.append(lazyStream), no?

  2. As for the blended stream itself, I think it's fine. I'm a little nervous about how it will behave in matters of laziness and what that might do to back pressure, but I really don't see a way other than progressing all streams.

  3. Performance wise I think it could be better to implement it by calling forEach on both streams and "simply" (pretty sure that part causes headaches) ensuring that the actual handler runs only on one of them at any given time. But I think that's for another time ^^

kevinresol commented 7 years ago

What's the TailedStream really about?

I removed it already, I think my mind was just stuck when I wrote that.

For 3. I will enhance it later

back2dos commented 7 years ago

@kevinresol can please you fix the test that goes with it?

kevinresol commented 7 years ago

:ok_hand: