Skip to content

Instantly share code, notes, and snippets.

@bpinedah
Created December 19, 2018 00:41
Show Gist options
  • Save bpinedah/c7678c41b47a975d9aca11e836a4206f to your computer and use it in GitHub Desktop.
Save bpinedah/c7678c41b47a975d9aca11e836a4206f to your computer and use it in GitHub Desktop.
Pipes article
const p1 = (n) => new Promise(resolve => {
setTimeout(() => resolve(n * 2), 3000);
});
const p2 = (n) => new Promise(resolve => {
setTimeout(() => resolve(n + 1), 2000);
});
const p3 = (n) => new Promise(resolve => {
setTimeout(() => resolve(n + 3), 1000);
});
p1(10)
.then(r => p2(r))
.then(r => p3(r))
.then(r => console.log(r));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment