[Feature Request]Set flow context directly in inject node

All depends which you are most comfortable with. Either is fine (especially if you label your nodes sensibly).

3 Likes

@zenofmud Just as dceejay pointed out, at this point I'm quite comfortable with JavaScript and often am setting multiple context variables or additional operations in the same function node. At first I heavily used the change node and did things the "Node-RED" way. TBH, I still use the change node when I'm just setting one or two vars due to it's simplicity, I just prefer being able to quickly copy/paste lines in the function node rather than having to select options over and over again for the change node. Perhaps I would like it more if the change node operated such that when you select a different option from the drop down (msg., flow., global.) adding additional rules items should keep the selected setting of the previous rule rather than defaulting to msg. every time.

Also while messing with the change node just now I realized it may have an unintended behavior. When placing a change node if I select the flow. or global. options then revert back to msg. it clears the text input box contents even though I don't want it to. Causing the user to spend additional time retyping the property names. IDK if this is intended of not?

4 Likes

For one time flow/global context I use

.. quite often.

2 Likes

Just my own thought.

An inject node should be an inject node
A change node should be a change node.

Inject being able to manipulate the context feels strange.

Whilst I can see the convenience in faster initialisation flows, my gut feeling is that I would always want to see the change node doing that.

Change : set/alter things
Inject : Inject a message

:man_shrugging:

4 Likes

That's just what I want :slight_smile:
If my PR doesn't get traction - I'll be using this from now :slight_smile:

Yes @marcus-j-davies , and an inject node with nothing downstream would be most odd visually as flows must start have a start and end.

1 Like

Quite. Done that often enough, that by now I always start with inject + change, even when I don't expect to use flow variables.

3 Likes

At first site, I said: Yeah! Great idea :slight_smile:
... but after a while I realised:

  • An inject is inject only, just like a "ping". Would be confusing, (especially for newbees,) if there would be something "hidden inside".

  • What happens if I have to copy the flow with basic component back to a previous version of Node-Red ?

This would totally break backward compatibility. :frowning:

(Somebody just asked here recently that NR should be stability and "industrial-focused" in sense of not breaking things at every new version. I agree!)

4 Likes