Context Watcher

I just posted a flow to the library that permits a user to watch memory based context variables and get an event with what changed.

Might be of use to some folk.

chrome_RU0ciSH6f3

8 Likes

Thanks Steve, will certainly give that a go. I've always felt that this was an obvious thing missing from context handling since so many other areas of node-red flows are event driven. Up to now, you really needed to use MQTT to get event driven flows like this.

Would love to see something built into core with an event node that could trigger flows.

Indeed, an event node could be made generic to listen for ANY event. Or at least any custom event output by Node-RED.

1 Like

I've already written one (just never posted it) - it only covered the internal events (like flows deployed etc)

Spoke with Nick some time ago about how best to bring this to community (contrib or core) - just never got around to finalising it.

Might resurrect it for V5

1 Like

I think such a node can only cover Node-RED runtime events. However, if we could extend the standard for context handling slightly, changes to context could generate suitable events. I have some front-end code that wraps a variable and generates events if an example is needed. But I know that other parts of node-red use wrappers for observability too.

Thanks a lot, will check this, I'm sure it will be helpful .

I see that * Only built in memory based context is supported * , I guess it would not be that hard to use it with permanent stored context as well .... I'll check that.

Thanks again

I don't believe that will work correctly as I've already said. It will likely work until you restart Node-RED. Other than the memory store, all other stores have to serialise/deserialise the data to get them into storage and back. That will certainly break any links or observers.

I've always been of the opinion that Node-RED core should have some kind of ability to turn on streaming of context data. i.e. when you are in context explorer, you could enable streaming for a given object and just view it there.

e.g. (see animation below)

Animation

Alternatively at least the ability to manually refresh an object. Right now it's possible to do this on a top-level object but not lower level objects.

Obvs there would be performance considerations.

Do you think there's any appetite for such a feature to be included in NR5?

2 Likes

I would love to see that. However, it would need careful checking of the impact on performance. Some of us have rather large collections of context variables. :smiley: