Is it possible to access node/flow/global context properties from a ui-template node?
As it is now I have to wait for the first message to show anything. It could be useful to either access the data on the server side, and send it to the client along with other initial state. Or to pull the data from the server, during loading/initializing.
We don't pass the whole global or flow context store to the client, only msg. So you'll need a "change" node ahead of where you want to access, then set something on msg. to expose the relevant property/value pairing.
So no ways to load a widget with data from the initial page load (immediately after loading external javascripts, etc. is done)? A change node would have to be messaged after the javascript in the template node is ready.
Could perhaps be an idea to access context values on the server side for embedding data as a javascript array, or whatever, so the widget can have some state, before the first message arrives?
It seems that at least some of the other nodes essentially do this. Like for example a graph showing data, before receiving any messages.
We have a widget-load event which is applicable here, but isn't exposed via an API to call.
Your best bet, if you want to ensure it's populated each time the widget is loaded is to use a ui-event, that will fire on page load, pass data to the ui-template node, which can store the msg, then once the library is ready, use this.msg accordingly.
If the chart loads first, the other option you have is to put a watch on msg, and then act when payload is set, checking if the library has loaded or not.
Multi-Tenancy Design Pattern: Getting Started | Node-RED Dashboard 2.0 (whilst you're not using it for multi-tenancy, the ui-event pattern described here is still really useful)