Where'd Promise#done go?
forbes at lindesay.co.uk
Thu Jun 20 05:55:17 PDT 2013
I've been answering quite a few questions about promises on stack overflow lately. One of the key things people seem to struggle to get their head around is the idea of `.then` as being something that transforms the promise and returns a new promise. They either expect it to mutate the existing promise or they expect it to behave like `.done()` does.
I think `.done()` could be extremely useful purely as a teaching device. If we started everyone off by learning to use `.done()` they would have a much shallower learning curve. Initially they'd get all their errors thrown immediately which would be easier to see. It would be much more similar to typical (but terrible) DOM APIs and jQuery APIs that are event based or have a callback and an errback. Having learnt to use `.done()` we could teach `.then()` as a more advanced feature that let you compose asynchronous operations by returning a promise that has been transformed by the callbacks.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss