Closed myndzi closed 9 years ago
Actually.. it seems it returns true or false, correlated with this very thing. Maybe add to the docs? Is this something that can be relied on?
Well, I made this: https://www.npmjs.com/package/kefir-node-stream
Streams2 only, but I think it's pretty thorough.
Yes, emitter.emit()
returns a boolean representing whether connected stream is still active. You can rely on that behavior. It's undocumented because still a subject to change, but most likely will stay.
That makes sense. Thanks.
I was writing a shim for Node streams (I feel like this should be in the library anyway?) and ran into a question about the behavior of Kefir.stream().
It seems as though, if you have multiple items from a source that you can emit, the only way to "correctly" do it is to wait a tick for each item so that unsubscribe can be called if necessary. This seems wasteful and slow. Am I missing something?
What about returning a value from
emitter.emit()
to let you know when to stop pushing data, as Node does with writable streams? This would allow you to synchronously produce any number of items for your stream but still consume them lazily.