I want to know the internal mechanism of local variable refreshing in an interface. When a local variable is refreshing, what is the underlying logic of the behavior? Is all code re-executed? Can you give me a conclusion and provide a demo to prove the conclusion.
Discussion posts and replies are publicly visible
This article might solve your all questions as different Local variables that are used within interfaces can refresh their values under a variety of conditions. https://docs.appian.com/suite/help/24.3/Local_Variables.html#:~:text=Local%20variables%20are%20a%20specific,data%20within%20a%20particular%20expression.
I have read this article before I raise this ticket, it can't solve my question, I want to know some more underlying mechanisms or principles. Like when the refresh behavior is occurring whether the code which will be not refreshed will be re-executed?
Appian had concepts of load() and with(),
If you use load(), the code engulfed by load will get evaluated only once. A local variable's value is only calculated the first time the expression is evaluated and is then loaded back into the expression each time the expression is evaluated again within the same context
If you use with(),it recalculates the local variable values after interactions. This recalculation always happens, even if the interaction's updates could not have impacted the variable's value
localVariables() can implement the functionality of load and with function for each local variable initialized using various refresh options in the a!refreshVariable function.
Please read through this for more related information
docs.appian.com/.../SAIL_Performance.html
Is there any way to verify the conclusion?
Play around the code to verify
a!localVariables( local!counter:0, local!randomValue:a!refreshVariable( value: rand() /*refreshInterval: 0.5*/ /*Refresh every 30 seconds*/ /*refreshOnReferencedVarChange: local!counter*/ /*Refresh when value of counter changes. Click on Add and see the change*/ /*refreshAlways: true */ /* Refresh always*/ ), { a!linkField( links: a!dynamicLink( label: "Add", saveInto: { a!save( local!counter, local!counter+1 ) } ) ), a!textField( value: local!randomValue ) } )
edwardc8281 said: I want to know some more underlying mechanisms or principles.
The underlying mechanics are not public and not published by Appian as far as I know. We know only what the official docmentation tells us (and what we can infer from experimentation).
What is your use case / what are you trying to accomplish?