Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deregister Listener when links are created #1011

Open
neetr opened this issue Jul 10, 2023 · 0 comments
Open

Deregister Listener when links are created #1011

neetr opened this issue Jul 10, 2023 · 0 comments

Comments

@neetr
Copy link

neetr commented Jul 10, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant