3 ms·
The general pattern is write code to do initial processing, set up promises, return a promise depending on those promises that will do something. The promises
by btilly 11y ago
The general pattern is write code to do initial processing, set up promises, return a promise depending on those promises that will do something.
The promises you set up should always be assumed to do things in whatever order they happen to happen. Your code that does interesting stuff happens before any promises are seen. The interesting code in your returned promise will happen after the necessary promises are resolved.
As long as things are always set up this way, you'll be fine no matter how the promise library is set up. Which is good because unexpected implicit dependencies are a problem.