You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have made my own promises library which attempts to expose an API similar to Javascript's own promises. However there is one thing which your spec doesn't provide (or I am confused): if the original promise (the one made with e.g. the constructor) will resolve with a thenable, what should the first .then() callback give?
The Promises/A+ then method does not support fulfilling with thenables (when returning them from the then callback`). This spec does not say anything about the constructor, it doesn't answer your question.
You can do either. You should decide whether the callback in your constructor is a resolve or a fulfill. You got three choices:
It fulfills the promise with the passed value. In that case final should be logging the promise2.
It resolves the promise, using thenable assimilation. In that case final should be logging 5.
It resolves the promise by adopting the passed promise. In that case final should reject, because promise1 and promise2 are rejected promises, because 5 was not a valid promise.
I'm pretty sure promise1 should resolve to the value 5, but otherwise thank you. I have chosen to call then() in the constructor (without that final would resolve to promise2 in my implementation)
Note that it passes all tests in the tests repo either way (it's inspired by RWPromises)
I have made my own promises library which attempts to expose an API similar to Javascript's own promises. However there is one thing which your spec doesn't provide (or I am confused): if the original promise (the one made with e.g. the constructor) will resolve with a thenable, what should the first .then() callback give?
What should be displayed for the first final promise? Should it be 5 or one of promise1 or promise2? The second one will display 5 anyway.
The text was updated successfully, but these errors were encountered: