refresh behavior in Interface

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

Parents
  • 0
    Certified Lead Developer

    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

  • 0
    Certified Lead Developer
    in reply to edwardc8281

    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
        )
      }
    )

Reply
  • 0
    Certified Lead Developer
    in reply to edwardc8281

    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
        )
      }
    )

Children
No Data