-
-
Save Leechael/56fd84fee27748974108accdd280e1e4 to your computer and use it in GitHub Desktop.
Resolving Promises Sequentially: Kefir.js version
This file contains 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
// https://hackernoon.com/functional-javascript-resolving-promises-sequentially-7aac18c4431e | |
// Kefir.js version. | |
// Just a demo. | |
var ids = [1, 2, 3, 4]; | |
var thenables = ids.map(i => { | |
let thenable = fetch(`https://httpbin.org/anything?id=${i}`) | |
.then(r => r.json()) | |
.then(obj => obj.args.id); | |
return Kefir.fromPromise(thenable); | |
}) | |
Kefir.concat(thenables).log(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment