Listen to events only when node is in use

Hi all!

Is there a way to listen to editor events such as deploy only if my node is in use? I read this page but I couldn't find a function I could override when my node is dragged from the palette to the workspace (HTML File : Node-RED).

Thank you for your help!

You will typically do this in your JS Module file.

module.exports = function (RED) {

    function Init(config) {"deploy", HandleDeploy);

    function HandleDeploy(){
       // Do something

    RED.nodes.registerType('MyModule', Init);

The above will come into contact when its already in a users flow
remember to destroy the listener if your node is restarted or removed from the flow :sweat_smile:

this.on('close', (removed, done) => {"deploy", HandleDeploy);
}) : Node-RED (

Hi! Thank you for your reply!
Unfortunately, I can't make it work in the JS Module file... it seems that editor events (such as deploy) can only be called from the HTML file (I am not sure tho).

My code is here, do you see any problem with it?

thanks again!