Question about flow with multiple tabs

#1

Node-red and MQTT is really taking over here these days, I've now got eight IOT devices (Raspberry Pi, PiZeroW, and Beaglebone MQTT broker) running, and node-red has saved me a ton of development time and effort. I'm a believer!

I have a question about multiple tabs on flow. Mostly I do only one tab in a flow on a single device, but for my AI enhanced security cameras I've an "interface" flow on one tab and a "notification" flow on a second, because the notification flow gets reused for each device since it doesn't change while the interface flow is pretty different for the different types of cameras.

I recently made a change that would want to pass data between the two tabs. I took the easy way out and and just duplicated the two MQTT subscribers that get the data and all seems to be working well.

I know nodejs is heavily threaded (such that you need to take precautions to insure sequential program execution) so I assume this applies to node-red. Are separate tabs run in separate threads?

What is the "best" way to pass data among flows on different tabs?

I've noticed export to clipboard offers three choices entire flow (all tabs) current tab, and selected nodes whereas export to library seems to only offer selected nodes which for me is a generally single tab after doing "select all" in the active tab. This seems the "right way" for saving/extracting subflows or a "resuable" tab like my notification flow, but for backing up the entire current flow before I start making changes it becomes a multi-step process to make a local backup copy.

#2

Multiple MQTT subscribers is not a problem as they all share the same connection to the broker so the data is only sent once, then distributed locally... but in general you can use the link nodes to link between different tabs.

No all tabs share the same node.js event loop, no threading is provided.

Yes - the library is due an overhaul - but we did recently introduce the projects capability that allows versioning of flows, git integration, etc.

#3

As @dceejay says you can use the Link node to flow between tabs. However if what you are doing is not a logical flow of messages from one tab to another then I would say it is better to do it the way you have. As I understand your description you would have on the first tab an MQTT In node feeding the logic there and it would just be the MQTT messages that would be linking to the other tab. In that case keep it the way you have, keep the interdependence between tabs to a minimum.

#4

Thanks guys, nice to know my instincts aren't totally wrong. I didn't notice the link node before, thanks for pointing it out to me. But, like the change node, it doesn't seem all that useful until you see and example or two and the aha moment.

Thanks again!