Our pure JavaScript Scheduler component
Hi,
We have some expensive resource traversals in our treeMenuToggle(). It's getting called for every visible element when expandAll() or collapseAll() is called.
Is there a way I can prevent that from happening? We only want treeMenuToggle() to emit on individual menu toggles.
Thanks for your time,
Derreck
Can you please provide some more context? What's treeMenuToggle
some code to look at would be helpful!
Sorry I meant that we have a expandnode & collapsenode listener that I do not want to execute on expandAll/collapseAll.
Is there a way I can prevent this? Maybe with something from the Event.source emitted on expandnode & collapsenode?
Or is there another way I can trigger an acton/function off a Tree toggle, without adding a listener for expandnode & collapsenode?
In the Docs the removeListener takes in a 'config' object (not a string). What is that config model/object suppose to look like to remove a listener?
I don't see a property there to remove/disable, other than the once property.
Just like with native DOM events you should use same params as when you subscribed.
const handler = () => {};
scheduler.on('foo', handler);
scheduler.un('foo', handler);
or use the 'detacher' function returned from the 'on' call:
Returns a detacher function unless configured with detachable: false. Call detacher to remove listeners
Scheduler.un and scheduler.removeListener take in an 'config' object not a string for me. Is there maybe a type issue?
Also, detachListeners ('expandnode') is not working either and what is the detacher function suppose to look like/do? Can't find it in the docs.
Yes, slight docs issue. Now fixed!
here's how to use detacher:
const detacher = scheduler.on({
someEvent : () => {}
});
// later
detacher();