onChange function triggered by msgs with _ui property

Not sure if this is working as intended, or I am missing something ?

Input messages containing a msg._ui property will not trigger the client libraries on-change method.

As you can see in the first line there is a _ui property in the msg, but its still passed to the onChange function.

If I manually filter out _ui msgs with if (msg.hasOwnProperty('_ui')) { return }; then all is well

[indexjs:uibuilder.onChange] msg received from Node-RED server: {topic: 'environmental', payload: 'cascade', _socketId: Array(2), _uib: {…}, _msgid: '94815bf9ae5eceb5', …}payload: "cascade"topic: "environmental"_event: "node:6045ca1c956d7a61"_msgid: "94815bf9ae5eceb5"_socketId: (2) ['RgRjL7ZZEDhrGfDfAAgi', 'cqiTC4XQdwBcHyT7AAAF']_ui: [{…}]_uib: {_socketId: 'cqiTC4XQdwBcHyT7AAAF', version: '6.1.1-iife.min', ip: '192.168.1.101', clientId: 'ONfleGFm9cTshF1P910LH', tabId: 't549481', …}[[Prototype]]: Object
index.js:36 emsg: null
index.js:37 Uncaught TypeError: Cannot set properties of null (setting 'value')

Ah, well, you might have spotted an inconsistency in the documentation :flushed:

In fact, I can confirm that sending something with msg._ui or msg._uib (which lets you control the client from Node-RED) will both trigger onChange. This is to do with uibuilder client's internal event handling.

You could use the onTopic handler if you have a specific topic you want to monitor.

Would there be interest in an onMsg function that didn't trigger on msg._ui or msg._uib? Or would that be more confusing? Or perhaps I SHOULD exclude them from the onChange handling?

Thoughts please.

Is that what we old timers call a Bug :wink:

So thinking out loud, Are messages with msg._ui likely to be used by OnChange functions ?
I guess only other users could answer that, to me the way it's documented makes more sense.

In this case, I would expect an onMsg function should listen for ALL messages, and allow the user to handle as required.

If you filter out _uib wouldn't this then cause problems, if messages are being re-routed back to uibuilder node to update other clients ?

No, no, absolutely not! How can you even suggest such a thing - of course it was a "late design decision". :wink:

I think you are right.

Yes, again correct.

OK, decision made - I'll update for the next release so that any input message that includes a msg._ui does not trigger the onChange('msg', ....) function. I will probably do the same for messages containing a msg._uib property but I just need to double-check that doesn't have any unintended effects.

Thanks for raising.

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