|
|
|
|
|
by mjackson
4367 days ago
|
|
> FRP streams go beyond promises by allowing many returned values. This is pretty nice, and shows how FRP is at least as powerful as Promises. The fact that you can only return a single value from a promise is a feature, not a limitation. In synchronous code, you can only return once from a function. In asynchronous promise code, you can only fulfill the promise once. There's a parallel. If you want to "allow many returned values" you can just use a callback. You hardly need a "stream" for that. |
|
Erm, have you heard a term "continuation" or "call/cc" ("call-with-curent-continuation")? Or "delimited continuations"? Or maybe even "Cont monad"? You should read on them, if you haven't - they are one of the most fundamental and fun concepts I encountered.
But even without those, what you wrote here is false in the presence of generators (which are coming to JS any day now!).
I'd say that returning more than once from function is actually a pretty basic technique which is widely used to implement quite a wide array of different things.