kriskowal / q

A promise library for JavaScript
MIT License
14.93k stars 1.2k forks source link

Make `notify` return a promise derived from `onProgress` return values/throws. #340

Closed domenic closed 10 years ago

domenic commented 11 years ago

See https://github.com/promises-aplus/progress-spec/issues/3#issuecomment-11609297. This would replace our current strategy of crashing if onProgress throws.

I believe it would be something along the lines of Q.all(progressHandlers.map(Q.fcall)).

kriskowal commented 10 years ago

This change could not land until v2. As it happens, notify and progress have been removed outright in v2, and if they are reintroduced, will not compose. Closing.

TimDaub commented 9 years ago

NOOOOOOOOOOOOOOOOOOOOOOOOOO

I'm trying to abort the hashing of a number of files and I'm using Q's promises to handle the async part. So since this is never going to work in 1.0, I guess its not possible to stop the execution of a promise from the outside or is it?

kriskowal commented 9 years ago

@tomdaub cancellation is an unrelated concern to progress/notify. Q promises have multiple consumer semantics, so cancellation is tricky. I am contemplating building a library with a "task" primitive that is similar to a promise but with explicit fork() and cancel(), and @domenic is actively working out whether promises can become cancelable promises with reference counting on observers.

See: https://github.com/kriskowal/gtor