Link routing on reload vs. during editing

Dear Support:

We don’t store link routes in our persisted files (to reduce source control merging issues), so they’re all computed when the diagram is loaded. However, we’d like it to be the case that what the user sees on the diagram always represents what they would see if they saved and restored the file.

In order to accomplish this, we’ve added this diagram listener:

// Arrange that all links are redrawn when anything is moved.
myDiagram.addDiagramListener("SelectionMoved", () => {
   myDiagram.links.each(function(l) { l.invalidateRoute(); });

This seems to work properly; anytime anything is moved, all links that may be affected are redrawn.

Is this the right way to approach the problem and do you have comments regarding this?

Thank you.

I don’t see why that would be necessary, as long as you do not allow users to reshape Links or modify other properties that would affect the computed route. Also you don’t want to set Link.adjusting.

Normal movement of nodes will automatically cause all connected links to recompute their routes.