I've been trying to make the link:add event handler work. But this is the first time I work with Editor events and the doc didn't say exactly where I should register the event handler from. So I tried to place it in one of my custom nodes like this:
module.exports = function(RED) {
RED.events.on("link:add", function(link) {
console.log("A link has been added to the workspace!");
})
function MyNode(config) {
....
}
}
Then when I added a node into my flow, wired it up to another node, and deployed the flow, nothing happened about that event handler.
I then moved it inside the node function and it was still the same.
So my question is: Where should I put this handler?
I've also seen warning elsewhere on the forum that
You need to be careful making use of RED.events since this is used internally by Node-RED. It would be easy to end up with a clashing event name and that could be super hard to diagnose.
This looks pretty scary. So I'd love to have advice on how to go about this.
Is nrlint still the preferred way than listening to these events?