Pontus ??stlund wrote:
22 maj 2016 kl. 16:40 skrev Marcus Agehall (nu med K-m??rkt fastighet och ny elcentral) @ Pike (-) developers forum 10353@lyskom.lysator.liu.se: A bigger problem imho is the difference in how promises are actually resolved. In JavaScript, the return value of then() is always a *new* promise which then allows for chaining. In Pike, we return the same promise object. This means that code like
my_promise->on_success(foo)->on_success(bar)
in Pike would result only in a call to bar() once my_promise is resolved whereas in JavaScript, foo() would be called and it's return value would be the input to bar in a new promise.
I agree that a new promise (or future rather) should be returned. You can blame me since on_success/on_failure were void functions originally so I added the return stuff so you could chain an on_failure onto an on_success. But you are correct, that should probably be a new future, and if on_success/on_failure returns a future that???s the one to be resolved in the next chained on_success/on_failure.
It seems that this has not been fixed yet. I'm trying to build a SOAP interface using Promises. It is messy at best.
Do we agree that this needs to be fixed? Any objections if I try to fix it?