Skip to content

Instantly share code, notes, and snippets.

@juice49
Created March 21, 2018 13:49
Embed
What would you like to do?
Promise once (sort of)
function promiseOnce () {
let promise = null
return function (createPromise) {
if (promise) {
return promise
}
promise = createPromise()
promise.then(() => {
promise = null
})
return promise
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment