Description
Ass suggested by @Raynos in #2 we could make promises lazy until .done
is called. Consider the promise(executor)
syntax being proposed in promises-aplus/constructor-spec#3
The executor is a function which initiates the asynchronous operation. It has the potential to generate either a resolved promise or a rejected promise. If it's not called, then no rejected promise can exist, so we don't have an issue. So the key idea being presented here is to only call it when we know the promise's rejection will be handled.
By only calling the executor once .done
is called, you can guarantee that .done
will always be called for all promises. If .done
is not called, the entire function will fail to do anything, which will be easy to quickly pick up when developing.
Having done that, it's a simple case of having .done
behave as in #5 and crash the application appropriately by throwing the exception in the next turn of the event loop.
Transition
Step 1, ad .done
to the promises spec.
Step 2, make sure all promise libraries call .done
if present when assimilating promises.
Step 3, wait a month or so for this to be true of most major promise libraries
Step 4, begin using console.warn
to warn people that they need to begin calling .done
when .done
is not called after a period of a few seconds.
Step 5, Implement this feature properly by making the promises lazy.