4 ms·
I think this completely changes what you have though, in a way that's no longer a primitive? You then have something like an async generator, which is like a f
by zimablue 9y ago
I think this completely changes what you have though, in a way that's no longer a primitive?
You then have something like an async generator, which is like a fusion of asynchrony and sequence?
Except generators are pull not push, so instead you have a promise that accepts a function that operates on a sequence?
I don't know if this pattern is common somewhere, someone who does please explain!
- amelius 9y agoIn Haskell you can generate a list lazily. The last item in the list could be the final result-value, whereas the leading elements could be the progress information. Canceling a computation could be done simply by stopping to "listen" to the result (i.e. stopping the evaluation process). I guess you could implement this in JS by having a promise-like structure which returns a tuple containing progress information AND a promise for the remainder of the computation. In a sense, this is similar to the generator approach. One problem is if your program execs an external program. At what point should a promise kill the external process?