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

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,

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?

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.

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 :confused:?

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.

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

ah! :slight_smile:
Thanks. Clear now!

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.

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

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