Last active
August 29, 2015 14:05
-
-
Save phated/1e61921d85579f1119a0 to your computer and use it in GitHub Desktop.
when.join antipattern?
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
| var promise1 = require('./promise1'); | |
| var promise2 = require('./promise2'); | |
| var promise3 = require('./promise3'); | |
| promise1() | |
| .then(promise2) | |
| .spread(promise3) |
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
| var when = require('when'); | |
| function promise1(){ | |
| return when.resolve('my promise1'); | |
| } | |
| module.exports = promise1; |
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
| var when = require('when'); | |
| function promise2(promise1){ | |
| return when.join(promise1, 'my promise 2', when.resolve('a third')); | |
| } | |
| module.exports = promise2; |
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
| function promise3(promise1, promise2, promise3){ | |
| console.log(promise1, promise2, promise3); | |
| } | |
| module.exports = promise3; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment