I'm writing a component ( displaymsg) that displays information taken from message sent to it without requiring a complete dashboard.
I use that because I would like not to have to create a full dashboard as the hardware where nodered runs on is not very big (in memory and in CPU) (it is a dragino lps8v2 gatway).
To keep that information visible after panel has been refreshed, I'd need to hook on "viewRedrawNode" called in views.js (view.js)
The line (5032) in views.js is RED.hooks.trigger("viewRedrawNode",{node:d,el:this})
The view-annotations.js module does hook it, but I didn't succeed to do the same in my custome node.
I must say that I don't know if it is due to my poor knowledge of javascript, or if it is not possible due to the model of node-red.
I don't know why you want to listen there but RED.hooks can only have one listener (RED.hooks.add()). That's why it doesn't work for you.
If you want to listen to a node change use RED.events.on("nodes:change").
Or what do you really want to listen to? The status? Because redraw is used to "rebuild" the workspace - the node display.
Thé "viewRedrawNode" hook IS thé Lost appropriate, because I need to bé informed that it has been redrawn and some date must bé added.
Thé hook système support several clients: tobdo si you can register to thé hook n'y Bâle of the hook DOT a specific Key In my case that will bé "viewRedrawNode.displaymsg".
M'y problem IS that the défaut RED.hook doesn't handles 'viewRedrawNode'....
Event on node change will be triggered to often, but I'll check if I Can use it .
Currently the editor hooks are not part of the public api of the editor. They are used internally. So there is a chance they change in a future release that would break you.
With that said, can you share how you are trying to use the hook? Note that it is an editor hook, not a runtime hook - so your use of it must be in the html file of your node, not the runtime js component.
Thé current version of m'y node IS published in npm dispaymsg.
Thé rough flow IS : node receives a message, forward it and post an asynchronous delayed treatment. This delay prevent overrun by allowing discard of previous untreated messages.
Only messages that match a simple filter are processes.
On the other side, messages are received, preprocessed if needed, and display by adding a svg field that displays thé information.
The problèm IS that when you open another tab and go back ton the original one, the node IS fully refreshed and the added field removed (until a New message arrives).
I intend to attach the dispayed info to the node, and when hook IS called, recreate the field and redraw it. Si thé last displayed info will stay visible.