UIBuilder Multiple Instances

I have seen a lot of references to how you only need one node as opposed to many when building for the default dashboard.

Does anyone have a good explanation for when to use multiple uibuilder instances vs 1 instance?

Also, when you are using 1 instance for multiple separate pages, are there good examples of how to route inputs from multiple flows into that 1 instance and get outputs split back out for use in the correct flow?

You might want to use multiple instances if you wanted to use a different framework - lets say REACT rather than VueJS.

Strictly speaking, there are no real reasons to want to use a second instance but I didn't want to restrict people as I couldn't predict what people might wish to do with uibuilder :slight_smile:

So use another instance any time you want to keep your own code separate. Or use it when you want to create a different level of security. For example, you might have a UI that doesn't need security and another that does. Using separate uibuilder instances would most likely be more secure.

You might also want to use a separate instance in order to force a separate websocket channel as you've mentioned.

I use link nodes to do that. Along with a careful choice of msg.topic (you don't have to use topic of course, you could use any other property you like). Then in my onchange method, I will test for the topic and branch out to the appropriate processing.

Handling output from the uibuilder node is the same. Make sure that you use a property (e.g. topic) so that you can switch and branch inside Node-RED as appropriate and use link nodes to send the msg to the right flow.

So restating what you said, it sounds like you use link nodes from the dedicated flows to the instance and then inside the onchange method very early on there is something like a select/case statement to break out the input based on topic (or any other consistent data location) to whatever needs its. Similarly you send output with a topic (or any other consistent data location) and likely feed it into a switch node that goes to a link node back to the flow that needs that output.

1 Like

One node to rule them all! :wink: :mage: