I'm using a Set
to maintain a bunch of functions where after calling it once, I can remove it from the set. This is my code below:
let onceWrapper = function() {
let args = arguments;
Set.delete(eventName, onceWrapper);
func.apply(this, arguments);
}
Set.add(eventName, onceWrapper.bind(this));
I'm noticing that when I set a breakpoint after the Set.add(eventName, onceWrapper.bind(this));
line, and run a Set.has(onceWrapper)
or Set.has(onceWrapper.bind(this))
in the console, it always returns false. Is there a way I could work around this? What is the explanation as to why my function changes? For what it's worth, when I console.log the function in the Set it returns [native code]
. Thanks :)