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
I've been using Q.spawn along with generators for a while now and I love it. The spawn method expects the generator function to return a promise on each iteration. My question is does it make sense to support streams also?. Streams are common in nodejs and will be coming to browser environments shortly. Also, since promises are basically a special case of streams it makes sense to support them.
The text was updated successfully, but these errors were encountered:
I may have explained myself badly when I said that promises are a special case of streams. What I meant was that a stream is a sequence of values in the future while a promise is a single value in the future. This analogy also links a number and an array of numbers together albeit with a different link. The spatial link. Please have a look the table in this paragraph for broader framework under which my statements fall.
This is what yielding a stream would look like. In the above example execution is halted until the stream ends. The spawn function would attach a event handler on event end or finish and call the next method (I don't know whether it should call it with a concatenated value of stream chunks or nothing).
I've come up with above example based on a recent use case. I don't have enough experience with streams, iterators or generators to suggest the precise behavior but if the aim of using spawn is to write async code that looks synchronous then streams must be handled too. If there is no support for yielding a stream then I have to yield a promise that resolves when the stream ends.
I've been using
Q.spawn
along with generators for a while now and I love it. Thespawn
method expects the generator function to return a promise on each iteration. My question is does it make sense to support streams also?. Streams are common in nodejs and will be coming to browser environments shortly. Also, since promises are basically a special case of streams it makes sense to support them.The text was updated successfully, but these errors were encountered: