Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to run a function when any variable changes?

How can I be notified when a variable is set? In any of the languages. (Preferably Harlowe, but if I have to switch language I could)

I dug into the Harlowe code, and found that VarRef contains exactly what I want, because there's a hook that lets you do like:

VarRef.on('set', (obj, name, value) => {
if (obj === State.variables) {
// You know that variable $name has just been set to $value
}
})

But I can't find a way to get access to this VarRef object. Any ideas?

Thanks
Sign In or Register to comment.