|
|
|
|
|
by AgentME
4368 days ago
|
|
A stream can be thought of like a function in a lazy language returning an array of results which aren't necessarily calculated (or available) all at once. >If you want to "allow many returned values" you can just use a callback. You hardly need a "stream" for that. Callbacks are hard to compose, may not have standard error conventions, and you can't have multiple listeners subscribe to the same thing after the fact. (Those are the same things that promises solve for async functions with a single result.) Additionally, you can stop listening to a stream and the source can know to close itself once it has no more listeners. |
|