Hello,
I have implemented a ModelChanged
listener to get notified when new links are added either by the user or programatically:
if (e.change === go.ChangedEvent.Insert && e.propertyName === "linkDataArray") ...
Now within that listener, I traverse the diagram, and I would like the diagram to already include the new link. For example, when using something like node.findLinksOutOf()
, the collection should include the newly added link. However, this is not the case currently. In the ModelChanged
listener, the link is not yet added to the diagram as it seems.
Is there a way to achieve the above described behaviour?
Using setTimeout
seems to work, but maybe there is a better way? Note that I cannot used the onLinkDrawn
handler as I also need to handle programmatically added links.
This is our use case:
The KT value of a node is calculated based on parameters of all successor nodes. So whenever a link is added (or deleted), I need to recalculate the KT value (as successors might have changed). And in order to recalculate the KT value I need to traverse the (updated) diagram.