I tried to implement this with an array and the values in the array were set. But only at the start of the layout.
How to check if the values of instance variables have changed, and if they changed, set the values in the array to the values of instance variables.
Here is my code in c3runtime/instance.js:
this.instance_vars = [];
this.defaultVarsValues = "";
for (let i = 0; i < this.GetInstance().GetInstanceVariableCount(); i++)
{
this.instance_vars[i] = this.GetInstance().GetInstanceVariableValue(i);
this.defaultVarsValues = JSON.stringify(this.instance_vars);
}