# RED.events inside function node?

**URL:** <https://discourse.nodered.org/t/red-events-inside-function-node/47519>\
**Category:** General\
**Created:** [23 June 2021 09:14 UTC](https://discourse.nodered.org/t/red-events-inside-function-node/47519 "2021-06-23T09:14:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [23 June 2021 09:14 UTC](https://discourse.nodered.org/t/red-events-inside-function-node/47519/1 "2021-06-23T09:14:25Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/6801e9746153accff2a4b97bab5635506263c3ba.png)

**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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 June 2021 11:40 UTC](https://discourse.nodered.org/t/red-events-inside-function-node/47519/2 "2021-06-23T11:40:49Z")

</div>

> [@H3llsing](#):
>
> i was wondering if its possible to use `RED.events.emit('myEvent',callback)` inside a function node?

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [23 June 2021 20:44 UTC](https://discourse.nodered.org/t/red-events-inside-function-node/47519/3 "2021-06-23T20:44:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [23 June 2021 22:24 UTC](https://discourse.nodered.org/t/red-events-inside-function-node/47519/4 "2021-06-23T22:24:16Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [24 June 2021 12:29 UTC](https://discourse.nodered.org/t/red-events-inside-function-node/47519/5 "2021-06-24T12:29:42Z")

</div>

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.

> **[TotallyInformation/node-drayton-wiser](https://github.com/TotallyInformation/node-drayton-wiser)**
>
> A (currently experimental) Node.js module for working with the Drayton Wiser smart heating system - TotallyInformation/node-drayton-wiser

---

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [24 June 2021 12:58 UTC](https://discourse.nodered.org/t/red-events-inside-function-node/47519/6 "2021-06-24T12:58:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 August 2021 12:58 UTC](https://discourse.nodered.org/t/red-events-inside-function-node/47519/7 "2021-08-23T12:58:36Z")

</div>

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