projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.45k stars 1.16k forks source link

Question: What event is fired when a link is formed. #933

Open jtwigg opened 2 years ago

jtwigg commented 2 years ago

Question: What event fires when a new link is formed and how to I register a listener for it?

I've read this issue start to finish but I cannot still cannot see a reasonable way to get an event to fire when a link is connected from port1 -> port2

https://github.com/projectstorm/react-diagrams/issues/750

This seems to be asking the same question too: https://github.com/projectstorm/react-diagrams/issues/845

amith2368 commented 2 years ago

If you are looking for event listener when a connection is made, here you go

model.registerListener({
        linksUpdated: (event) => {
           event.link.registerListener({
               targetPortChanged: (event) => {
                   console.log('Link Changed');
               }
           })
        }
    });