const thing = () => {
// returns a promise with data
}
thing()
.then(delayPromise(100))
.then((data) => {
console.log(data);
});
Last active
January 17, 2016 18:22
-
-
Save philpoore/32eaf50eec6451e89f6a to your computer and use it in GitHub Desktop.
Javascript Delay Promise with Arguments
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
// Delay a JS Promise by a number | |
// of miliseconds. Preserves arguments. | |
const delayPromise = (duration) => { | |
return (...args) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(...args); | |
}, duration); | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment