Refresh a variable in custom time interval

Certified Associate Developer

I was trying out this plugin called "Timer Component". It basically provides us with a stopwatch functionality. We can also stop it automatically at some given time interval. I just tried to create a functionality where this plugin can be used to refresh a variable automatically in custom time intervals ( also less than 30 sec). Is it a good way to do it?

a!localVariables(
  local!total: 50,
  local!bool: false,
  local!refreshAfter: 5,
  {
    stopWatchField(
      /*label: "Stopwatch Timer",*/
      labelPosition: "ABOVE",
      validations: {},
      height: "AUTO",
      action: "START",
      size: null,
      align: null,
      expiredMessage: null,
      color: "#FFF",
      style: null,
      timerDirection: null,
      enableReverseTimer: null,
      reverseTimerColor: null,
      secondsValue: local!total,
      secondsSaveInto: {
        a!save(
          local!bool,
          not(local!bool)
        ),
        a!save(
          local!total,
          local!total-local!refreshAfter
        ),
        if(
          local!total<30,
          a!save(local!total,50),
          {}
        )
      },
      enableAutoStop: true,
      autoStopTimerSeconds: local!total-local!refreshAfter,
      autoStopType: "AT"
    )
  }
)

  Discussion posts and replies are publicly visible

Parents
  • As much as I understand, 30 seconds was added with the thought that refreshing variables in less than that time will have performance impacts on the interface and its components. 

    If the save is just a trivial one with no complexity (eg. changing the value of a single integer variable), then it won't have any severe impact but as the save gets more complex, it will have an impact that will increase with the complexity.  

    So I guess unless it is

    1. very necessary to refresh it in less than 30 seconds
    2. No complex calculations, saves and dependencies are there on the refresh happening
    3. And you want to create a dependency on a custom plugin

    then it is okay to use else try not using it for altering the refresh intervals. 

Reply
  • As much as I understand, 30 seconds was added with the thought that refreshing variables in less than that time will have performance impacts on the interface and its components. 

    If the save is just a trivial one with no complexity (eg. changing the value of a single integer variable), then it won't have any severe impact but as the save gets more complex, it will have an impact that will increase with the complexity.  

    So I guess unless it is

    1. very necessary to refresh it in less than 30 seconds
    2. No complex calculations, saves and dependencies are there on the refresh happening
    3. And you want to create a dependency on a custom plugin

    then it is okay to use else try not using it for altering the refresh intervals. 

Children