Skip to content

Instantly share code, notes, and snippets.

@juice49
Created March 21, 2018 13:49
Show Gist options
  • Save juice49/fe1c2709812b95c93869b5a1bb42551b to your computer and use it in GitHub Desktop.
Save juice49/fe1c2709812b95c93869b5a1bb42551b to your computer and use it in GitHub Desktop.
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