I can kind of see what you are meaning and sure I can see a way of doing it.
But honestly, I am behind the other people who say there is an easier way.
But to indulge your idea, this is how I would do it:
(Sorry this if being typed on the fly and I am making it up as I go along. So there may be bugs in what I say.)
inject node and set it up to pulse outputs at .... what ever frequency you want.
That output goes into your node.
The code will be something like: (and here comes the seat of your pants part)
var a = flow.get('name'); // The global thing you are watching for change.
var b = context.get('name'); // A local store so it knows if the global thing has changed.
if (a !=b)
// The flow variable has changed.
// Do something here and save the new value to context 'name'
// But you will need (most likely) an output to action something happening.
But MQTT would simplify and allow so much more use of what you are wanting to do that how you are doing it.
I can get that you are wanting to do this to learn. Been there a lot myself.
By all means try.
I hope you can get it working.
But I think that you are making something which can be done easily a lot harder than it needs to be.
Don't be afraid to try MQTT once you have this nut cracked open.