FlowingCode / SimpleTimerAddon

Vaadin Flow integration of https://github.com/annsonn/simple-timer
Apache License 2.0
5 stars 3 forks source link

Continues requests when timer is running #4

Closed mlopezFC closed 4 years ago

mlopezFC commented 4 years ago

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

javier-godoy commented 4 years ago

This happens because currentTime is synchronized and current-time-changed fires on each animation frame: https://github.com/FlowingCode/SimpleTimerAddon/blob/29689b93df4f895acb38f0d02a66919e4d3ccfa3/src/main/java/com/flowingcode/vaadin/addons/simpletimer/SimpleTimer.java#L145-L148

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

mlopezFC commented 4 years ago

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

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)