Can a custom node have a function as a property?


I have a custom node currently in use that allows for a selection to be made in the config panel via drop down which is a dynamic list of end points. Current behavior is on selection, the endpoint is accessed and the data is parsed and saved to a static property value of the node/config for use downstream.

The Problem:

If the endpoint has had a data change, our saved value in node/config is no longer reflective of the actual endpoint data.

The Desire:

I would like to maintain compatibility with the property name in use, but instead of the property supplying the saved static value, I would like the property to call a function to retrieve/parse/return the data to the caller without introducing a breaking change for current users of the node ideally.

I've tried:

  1. defining a function as the value for the relevant key in defaults
  2. removing the key from defaults, defining the function outside of defaults

Neither has worked.

Is it possible to define a property as a function for a custom node in node-red ?

If the endpoint has updated data, how do you expect to know? Is it that you want your node to query the endpoint every time it receives a msg input?

If so, you don't need to save anything in the Editor, you need to call the endpoint from the runtime instead .

If not, what triggers a new fetch of the data?