And, in the same vein, why do promise libraries typically not provide a resolve()
and reject()
method on the promise itself, bypassing the need for a deferred object?
EDIT
OK, I understand and accept the importance of throw safety.
Additionally... I have been using promises in an eventually-resolved callback scenario which seems to require the defer pattern. That is, I have a class which will eventually be loaded with data and which exposes a promise as way to "listening" for the "loaded" event. The client will need to gain access to that callback-promise before any asynchronous activity has even begun. In this case, I use defer to generate a resolvable promise. Does this sound legit? Any suggestions for a better approach?