Tuesday 29 October 2019

Vuex resolve

Both of your examples should behave pretty much the same.
A value returned inside a then() handler becomes the resolution value of the promise returned from that then(). If the value returned inside the .then is a promise, the promise returned by then() will "adopt the state" of that promise and resolve/reject just as the returned promise does.
In your first example, you return "bbb" in the first then() handler, so "bbb" is passed into the next then() handler.
In your second example, you return a promise that is immediately resolved with the value "bbb", so "bbb" is passed into the next then() handler. (The Promise.resolve() here is extraneous).
The outcome is the same.
If you can show us an example that actually exhibits different behavior, we can tell you why that is happening.

No comments:

Post a Comment