promises-aplus / cancellation-spec

Discussion and drafts of a possible promise cancellation spec.
24 stars 5 forks source link

Tasks: single-consumer not-quite-promises #13

Open domenic opened 10 years ago

domenic commented 10 years ago

@kriskowal makes the case here: https://github.com/kriskowal/gtor/blob/master/cancelation.md

After thinking on this for a while, it's pretty elegant. By re-using the .then interface, they can be converted to promises easily (via Promise.resolve(theTask)), which makes them multicast.

@nathan7 and I were talking about this at NodeConf EU; tagging him in.

edef1c commented 10 years ago

The big question here imo is whether we should make them thenables, or have explicit conversion with a Task<T>#toPromise() → Promise<T> Maintaining the cancelability of a task even if it is returned asynchronously seems like a useful property to me. The interface proposed by @kriskowal is literally the same thing we came up with (sans the ETA stuff), so that's probably what we should go for.