I'm passing the resolve
function as a param, and I have to know if it had been called somewhere. Instead of manually maintaining a state, I'm wondering if there's a function can do it for me.
const p = new Promise((resolve, reject) => {
f(resolve)
g(resolve)
}
if resolve have been called in f
then g
should have different behavior, for example
const arr = [1,2,3]
const g = resolve => {
if(resolve has been called) {
do nothing
} else {
const el = arr.pop()
resolve(el)
}
}
I'd like to have a function f(resolve) == true|false
I know there's no standard function like this yet since it's not included in the promise spec. So I'm asking for a proposal which has been implemented in the browser or a polyfill.
If both not now, I'll just leave this question open here in case that some day in the future, there comes one.