I was reading on a blog about Promises and they show a problem that I don´t get at all. The blog is: https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html.
The writer presents 4 puzzles with a grafical solution:
Puzzle #1
doSomething().then(function () {
return doSomethingElse();
}).then(finalHandler);
Puzzle #2
doSomething().then(function () {
doSomethingElse();
}).then(finalHandler);
Puzzle #3
doSomething().then(doSomethingElse())
.then(finalHandler);
Puzzle #4
doSomething().then(doSomethingElse)
.then(finalHandler);
Here doSomething() and doSomethingElse are promises.
Can anyone explain everyone detailed? On the first one I get the order of execution. On the second, I dont get why doSomethingElse and finalHandler starts and finish at the same time. On the third, I dont get why doSomething and doSomethingElse starts at the same time. Shouldn´t doSomethingElse starts at the end of doSomething? On fourth, I dont get nothing...