RED.events inside function node?

Hey there,
i was wondering if its possible to use RED.events.emit('myEvent',callback) inside a function node?

EDIT
does not look like it's available
image

EDIT2
i just created a custom node which emits a nodeRED event
still a solution inside the function node or any other core nodes would be preferred.

Isnt this what multiple outputs on a function are for?

How are you to planning on receiving these events - in another function node with RED.events.on("myEvent",function(){})?

Pretty sure that goes against the whole visual wiring design.

1 Like

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.

Funnily enough I had a brief discussion with Dave about that the other day.

You might want to create your own event listener, it is pretty easy as it is a standard Node.js library.

Hey thanks for the Info with the clash possibillity.
I'll keep it in mind.
Yes it is nothing for every user. Im working on a project extending nodered for my company. And we are using a node with a c++ compiled code inside which establishes a communication with an company protocol. These nodes are sharing the same lib.
So it can be possible that 2 different nodes using internaly the same c++ client.
I needed a way to inform all nodes that the global configuration file has been changed. So that they can disconnect and reestablish the connection with new configuration :slight_smile:

In that case, I recommend creating your own event handler, that will be much safer and really no harder.

This package, while not specifically Node-RED (it works anywhere but I import it and use it in Node-RED, I'll probably get round to writing a proper node-red node one day!) makes extensive use of events.

1 Like

I have already implemented an own Emitter based in the nodejs emitter class :slight_smile:
since you were recommending this and it makes absolutely sense!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.