then() doesn't take on promise returned by called handler
Nakroma opened this issue · 1 comments
Nakroma commented
In the docs its stated that The call to .then also returns a promise. If the handler that is called returns a promise, the promise returned by .then takes on the state of that returned promise.
So .then(my_func()) should take on the promise returned by my_func()
Take a look at this example:
def testfunc():
return Promise(lambda resolve, reject: resolve("second"))
Promise(lambda resolve, reject: resolve("first")).then(testfunc()).then(lambda res: print(res))
The first .then
should take on the state of the promise returned by testfunc(), so in theory the second .then
should print out "second". But this is not what happens, instead it prints out "first" from the first promise.
Nakroma commented
Nevermind. Apparently resolve() absolutely needs an argument and the function absolutely needs a lambda.