Binding ports in links

Is there a way to change ToPort and FromPort dynamially in links?

I want my links to have different ports depending on values in the attached nodes but as these values may change I would prefer not have to go through all attached links and change their port values but rather have that as a binding in the link template or something similar. What would be the recommended solution?

You can set any given Link’s toPortId and fromPortId to control this, but since you cannot bind from one object to another object, you will probably have to go through all links, unless I misunderstand you.

That was what I was afraid of.

First I used this:

linkFromPortIdProperty: (linkData) => { return this.CalculateFromPort(linkData); },

Where CalculateFromPort is my own function where I checked the connected nodes and returned a portID.This worked, however not when anything changes as linkFromPortIDProperty is not called when underlying nodes changes. So I guess I have to set the portID properties in all affected links every time a node is changed.

Thank you for the reply