Retain connections to re-ordered outputs

So,

I am using the editableList UI widget, that is also responsible for spawning output pins.
This all works well, I can add/remove/re-order so on and so forth.

I have a function for outputLabels that returns the name of the 'rule', etc etc

However, when I re-order, the logic works, BUT - the original connected wires are still in their position, and not moved around - much like the switch node does.

So I end up with the messages hitting the incorrect connected nodes.

What is the magic ingredient, for retaining the connections to the pins - only having them shifted - likes the pins are?

Thanks

I haven't looked at the source but I imagine it also reorders the wires array. You can see this if you export any node there is a wires property in the object.

That does sound logical - looking at the switch source - I can't see anything that would hint at the re-ordering of wires.

This is a good area of interest though. :+1:

The magic is in the outputs property your node sets. Rather than a simple number, you can set it to an object that maps "old" to "new".

I can't be more specific at the moment... stood in a queue for a rollercoaster at Legoland. Have a look at the Switch node for an example.

2 Likes

Nice!

I'll explore - thanks

Side Note: We want a picture of the moment you pass out :+1:

8 Likes

Ok,

I have studied the switch node - it seems to be doing something _i and i
I don't have a UI element (hidden or otherwise), that controls outputs,
but I am setting my outputs property on oneditsave.

via processing the editableList array which is working as expected.

My attempts at trying to create an object for outputs, simply results in the node just disappearing when being saved. or dragged into the flow.

On further investigation, I need to set _outputs as the new 'change map', assumably this is like a temporary map, for the flow to re-configure its connections.

However, this also does not re-order the wires.

I am setting random numbers for the ID {"45454354":0,"454354343":1},
this make no difference, and I not able to get the node to work like the switch node.

How is the ID associated to the output? is it based on key order?

I found this, from which I am trying decipher.

Thanks

OK,

I have sussed it.

It seems the connection ordering is dependent on an input control with id node-input-outputs
setting it directly i.e node.outputs | node._outputs has no affect.

Looking at editor.js it will re-order the connections using only the input control.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.