Maybe a silly question, but a concept that still i struggle to figure out.
Talking about template node (Dashboard 2) and function node (base Node Red), am I right if i think as "running only at client level" (in the browser) for the first and running on server side (Node.js instance) for the second ?
If so, a View / Controller mode (splitting view functions from regular program flow) has to be implemented to correctly handle program flow, even when no UI are opened in the browser ?
Many thanks.
Yes ('ish).
No.
In reality, the ui_template node as with all of the Dashboard nodes, spans the server and client. If no clients are connected to your Dashboard, a Dashboard node may choose to cache the latest information sent to it so that a newly connecting client will automatically receive it. I think this might be optional in D2 - not sure though as I don't really use D1 or D2.
The dashboard node itself is defined & running on the server side (same as inject, function etc.). The node is associated with one or more widgets, which are the actual client-side HTML elements (instantiated per each client page which contains this node).
When a dashboard node receives a message on its input port, the message is automatically broadcasted to all connected clients, and received/processed (in parallel) by all its respective widgets.
Node-red dashboard framework has mechanisms enabling the server node to save and restore its widgets' content, but it is up to the node to implement this. Simple nodes (e.g. ui-text
) store their latest value in the server, and restore it upon client load/refresh. Other nodes save the history of the latest incoming messages, and replay it upon load. And other nodes do nothing and use default values or rely on the flow to re-populate the widgets upon page load.
Of course, this all refers to view/controller mode. If you do not want the widget to have a shared value across clients (e.g. in user-input fields) you need to flag it as a per-client node.