Last active
November 24, 2015 20:49
-
-
Save raganwald/d768caadd208fcdf436e to your computer and use it in GitHub Desktop.
Maybe I don’t understand promises, either.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // I expect: | |
| doSomething().then(doSomethingElse()) | |
| .then(finalHandler); | |
| // To act like: | |
| /* | |
| doSomething | |
| |-----------------| | |
| doSomethingElse(undefined) | |
| |------------------------| | |
| resultOfDoSomethingElse(resultOfDoSomething) | |
| |------------------------------------------| | |
| finalHandler(resultOfDoSomething) | |
| |------------------| | |
| */ | |
| // or: | |
| /* | |
| doSomething | |
| |-----------------| | |
| doSomethingElse(undefined) | |
| |--------------| | |
| resultOfDoSomethingElse(resultOfDoSomething) | |
| |------------------------------------------| | |
| finalHandler(resultOfDoSomething) | |
| |------------------| | |
| */ |
Author
You are not wrong.
Assuming of course:
doSomething returns a promise
resultOfDoSomethingElse also returns a promise, but for some reason required the value returned from doSomething
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that my assumption is that
doSomethingElseis a function that returns a function that returns a promise.