# Are there any more events than "input" and "close"?

**URL:** <https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835>\
**Category:** Developing Nodes\
**Created:** [13 September 2020 20:16 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835 "2020-09-13T20:16:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmnobre](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jmnobre](https://discourse.nodered.org/u/jmnobre)\
**Post date:** [13 September 2020 20:16 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835/1 "2020-09-13T20:16:12Z")

</div>

Good evening,

After a long search, the only 2 node events that I saw documented are the _input_ and the _close_...  
Are there any others? In particular, is there an event that signals when a node is first loaded?

Best Regards,  
José

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [13 September 2020 21:25 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835/2 "2020-09-13T21:25:21Z")

</div>

The docs are complete in terms of what is available for a node to use.

The node constructor is called when the node is being started. How does that differ to what you'd like to be notified of?

---

<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:** [13 September 2020 23:41 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835/3 "2020-09-13T23:41:31Z")

</div>

Specifically, all of the code contained in your .js file is loaded and executed when Node-RED starts or when your node is installed (using the pallet manager). My jktesting node contains quite a few annotations that indicate when things happen.

---

<div class="post-metadata">

**Author:** ![jmnobre](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jmnobre](https://discourse.nodered.org/u/jmnobre)\
**Post date:** [14 September 2020 08:16 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835/4 "2020-09-14T08:16:55Z")

</div>

Hi knolleary...  
For what I'm searching, in fact, the .ctor could work... was silly of me not considering it.  
Nevertheless, I was looking at the docummentation and only have found the 2 I specify... are there more? Was I looking at the [wrong place](https://nodered.org/docs/creating-nodes/) 😕?

---

<div class="post-metadata">

**Author:** ![jmnobre](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jmnobre](https://discourse.nodered.org/u/jmnobre)\
**Post date:** [14 September 2020 08:21 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835/5 "2020-09-14T08:21:48Z")

</div>

Thanks for the reply...  
When you say _when your node is installed_, you refer to when the node is dropped on the flow or when the flow is deployed?

I found your module... going to play around w/ it. Thanks.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [14 September 2020 08:36 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835/6 "2020-09-14T08:36:09Z")

</div>

> [@jmnobre](#):
>
> I was looking at the docummentation and only have found the 2 I specify... are there more?

As I said, the docs are complete in terms of the events available for them to use - the `input` and `close` events.

---

<div class="post-metadata">

**Author:** ![jmnobre](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jmnobre](https://discourse.nodered.org/u/jmnobre)\
**Post date:** [14 September 2020 08:37 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835/7 "2020-09-14T08:37:36Z")

</div>

ah! 🙂  
Thanks. Clear now!

---

<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:** [14 September 2020 12:48 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835/8 "2020-09-14T12:48:11Z")

</div>

> [@jmnobre](#):
>
> When you say _when your node is installed_ , you refer to when the node is dropped on the flow or when the flow is deployed?

It is when Node-RED starts its flows. That is when the appropriate node.js `require`'s are run.

Watch out for v0.3.2 of the jktesting node - I'll publish it shortly. That contains a couple of extra log outputs that show you exactly where the module is `require`'d and when the `module.exports` function is run. They both appear **before** Node-RED's "Starting flows" message.

```plaintext
1|Node-RED | 14 Sep 13:30:35 - [info]
1|Node-RED | Welcome to Node-RED
1|Node-RED | ===================
1|Node-RED | 14 Sep 13:30:35 - [info] Node-RED version: v1.1.2
1|Node-RED | 14 Sep 13:30:35 - [info] Node.js version: v12.16.2
1|Node-RED | 14 Sep 13:30:35 - [info] Windows_NT 10.0.19041 x64 LE
1|Node-RED | 14 Sep 13:30:37 - [info] Loading palette nodes
1|Node-RED | [jktesting] ***jktest.js is now being loaded into memory and executed***
1|Node-RED | [jktesting] ***jktest.js module.exports function executed (RED object now available)***
1|Node-RED | node-red-contrib-jktestEditableList - initialising module. Module Version: 0.3.1
1|Node-RED | node-red-contrib-jktestEditableList - loading module
1|Node-RED | 14 Sep 13:30:44 - [info] +-----------------------------------------------------
1|Node-RED | 14 Sep 13:30:44 - [info] | uibuilder initialised:
1|Node-RED | 14 Sep 13:30:44 - [info] | root folder: C:\src\nr2\data\uibuilder
1|Node-RED | 14 Sep 13:30:44 - [info] | version . .: 3.0.0-dev.4
1|Node-RED | 14 Sep 13:30:44 - [info] | packages . : vue,bootstrap-vue,socket.io,vue-draggable,http-vue-loader,moonjs,normalize.css,vue-moment,uibuilder-vuejs-component-extras,jquery,bootstrap
1|Node-RED | 14 Sep 13:30:44 - [info] +-----------------------------------------------------
1|Node-RED | [NRTEST:module] RED.settings.contextStorage { default: { module: 'memory' }, file: { module: 'localfilesystem' } }
1|Node-RED | 14 Sep 13:30:44 - [info] Dashboard version 2.23.0 started at /nr/ui
1|Node-RED | 14 Sep 13:30:45 - [info] Settings file : C:\src\nr2\data\settings.js
1|Node-RED | 14 Sep 13:30:45 - [info] HTTP Static : C:\src\nr2\public
1|Node-RED | 14 Sep 13:30:45 - [info] Context store : 'default' [module=memory]
1|Node-RED | 14 Sep 13:30:45 - [info] Context store : 'file' [module=localfilesystem]
1|Node-RED | 14 Sep 13:30:45 - [info] User directory : C:\src\nr2\data
1|Node-RED | 14 Sep 13:30:45 - [warn] Projects disabled : editorTheme.projects.enabled=false
1|Node-RED | 14 Sep 13:30:45 - [info] Flows file : C:\src\nr2\data\flows_DESKTOP-M1M6R28.json
1|Node-RED | 14 Sep 13:30:45 - [info] Server now running at http://127.0.0.1:1880/red/
1|Node-RED | [jktest.js] runtime-event: { id: 'runtime-state', retain: true }
1|Node-RED | [jktest.js] runtime-event: {
1|Node-RED | id: 'runtime-deploy',
1|Node-RED | payload: { revision: 'ee4d36a13e451a550d834c40a2c20fc4' },
1|Node-RED | retain: true
1|Node-RED | }
1|Node-RED | 14 Sep 13:30:45 - [info] Starting flows

```

You can also see from the output of the Node-RED events for the node that startup effectively seems to do a deploy which makes sense. However, if you subsequently do a deploy, you will notice that the 1st two outputs are **NOT** repeated. That is because doing a `require` of a module in node.js caches the module so a re-deploy will not reload the module. That is why you have to restart Node-RED if you make a change to a node module.

---

<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:** [28 September 2020 12:48 UTC](https://discourse.nodered.org/t/are-there-any-more-events-than-input-and-close/32835/9 "2020-09-28T12:48:16Z")

</div>

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