Skip to content

Instantly share code, notes, and snippets.

@Leechael
Created August 29, 2018 08:03
Show Gist options
  • Save Leechael/56fd84fee27748974108accdd280e1e4 to your computer and use it in GitHub Desktop.
Save Leechael/56fd84fee27748974108accdd280e1e4 to your computer and use it in GitHub Desktop.
Resolving Promises Sequentially: Kefir.js version
// 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