cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos

OnChange Events for variables

Have an OnChange event for variables. This would simplify situations where you want to have several events change a variable, but you want certain things to happen when the value of the variable changes and you don't want to repeat that OnChange logic in many places. When declaring a variable with Set or UpdateContext you could set the OnChange event by adding a third parameter. You could even support other types of event handlers by making the third parameter a record with OnChange as one of the columns in that record.


This would still work:

UpdateContext({MyVariable:"MyValue"});

This would be a new equivalent:
UpdateContext({MyVariable:{Value:"MyValue"}})
And this would be supported:
UpdateContext({MyVariable:{Value:"MyValue",OnChange:<Do Something>});

Similarly:
Set(MyVariable,MyValue,<Do Something>) 
or perhaps
Set(MyVariable,{Value:MyValue,OnChange:<Do Something>});

When setting a variable without specifying the event, the event would remain unchanged, so later updates would trigger the same event logic.

This would be a very powerful way of creating subroutines that can be triggered from anywhere by updating a variable.

Status: New