Open paulstelian97 opened 5 years ago
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:
final
should be logging the promise2
.final
should be logging 5
.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.