FlowingCode/SimpleTimerAddon

Continues requests when timer is running

Closed this issue · 2 comments

When the timer is running there are continuous requests sent to the server, a better way of dealing with this is needed.

This happens because currentTime is synchronized and current-time-changed fires on each animation frame:

@Synchronize("current-time-changed")
public BigDecimal getCurrentTime() {
return BigDecimal.valueOf(getElement().getProperty("currentTime", 0d));
}

getCurrentTime should be asynchronous, or at least updated on a debounced event instead of @Synchronized

Based on that, I'm thinking about two approaches that could be implemented:

  • Possibility of configuring how often the "current-time-changed" event can be fired from client side (ie: every 1 second, 5 seconds, etc.)
  • Adding a new method that will function asynchronously (ie: receiving a lambda, etc.)

Maybe it would be nice to have the possibility of disabling the listening of the events would be nice (ie: if I want to obtain current time asynchronously I would prefer not to receive requests for synchronizing the current time)