Hi,
I have registered a listener like:
model.registerListener({
linksUpdated:(e) => {
e.link.registerListener({
targetPortChanged:(event) => {
if(e.link.getLabels().length === 0) {
e.link.options.name=getLinkName();
const index = e.link.getLabels().findIndex((l) => l.getOptions().linkId === e.link.getOptions().id);
if(index === -1){
e.link.addLabel(new DefaultLabelModel({ label: getLinkName(),linkId:e.link.getOptions().id}));
}
}
The method getLinkName(), which is added as the Label is using a state variable to keep count of the number of links, so that the labels generated are Link1, Link2, Link3, etc
From what i read the count at the time of registering the listener is what will be used, and will not pick up from the state whenever the link is created. So i am trying to deregister the listener when the state variable linkCount is updated. Only i cant find much documentation on how i can deregister this listener.
Can someone pls help with an example?
Thanks,
Neet
Hi,
I have registered a listener like:
model.registerListener({
linksUpdated:(e) => {
e.link.registerListener({
targetPortChanged:(event) => {
if(e.link.getLabels().length === 0) {
e.link.options.name=getLinkName();
const index = e.link.getLabels().findIndex((l) => l.getOptions().linkId === e.link.getOptions().id);
if(index === -1){
e.link.addLabel(new DefaultLabelModel({ label: getLinkName(),linkId:e.link.getOptions().id}));
}
}
The method getLinkName(), which is added as the Label is using a state variable to keep count of the number of links, so that the labels generated are Link1, Link2, Link3, etc
From what i read the count at the time of registering the listener is what will be used, and will not pick up from the state whenever the link is created. So i am trying to deregister the listener when the state variable linkCount is updated. Only i cant find much documentation on how i can deregister this listener.
Can someone pls help with an example?
Thanks,
Neet