Closed tomosnam closed 3 years ago
I find these in source code. It may help.
registerListener(listener: L): ListenerHandle {
const id = Toolkit.UID();
this.listeners[id] = listener;
return {
id: id,
listener: listener,
deregister: () => {
delete this.listeners[id];
}
};
}
deregisterListener(listener: L | ListenerHandle) {
if (typeof listener === 'object') {
(listener as ListenerHandle).deregister();
return true;
}
const handle = this.getListenerHandle(listener);
if (handle) {
handle.deregister();
return true;
}
return false;
}
I think instead of this let glh = node.getListenerHandle(this.showWindow)
you need to deregister directly from node. Like this node.deregisterListener(listener: L | ListenerHandle)
OK, thank you.
Hi, I am registering the following event on each node: showWindow = (item) => { ondblclick = (event) => { ...
} } And my question is: How to deregister the event? I have tried the following and it doesn't work:
const nodes = this.state.diagramEngine.getModel().getNodes() nodes.forEach((node) => { let glh = node.getListenerHandle(this.showWindow) glh.deregisterListener() })