Hey all,
I’ve been working on a project that requires multiple countdown timers which may vary in speed as well as may be cancelable at any time during the countdown.
My server-side solution involves:
- A constant heartbeat connection that iterates through all tagged instances which may have an active countdown (single-digit quantities, and does not need to scale to n items)
- A check for whether or not a countdown to occur, based on an attribute.
- A separate attribute change taking a base constant + a multiplier.
I’m not sure about my client-side solution, though I could have:
- A tween which is destroyed and remade should the speed of countdown change (doesn’t sound efficient, though the removal+creation should not occur too often).
- A connection to the attribute change that modifies the value of the UI on the client end (sounds more efficient, though may result in some ugliness as the UI will not move smoothly?).
I’m satisfied-ish with my current server-side solution as I don’t believe there is a way to really accomplish a countdown without running some sort of loop, though there may be some optimization that can happen with iterating through active countdowns rather than polling each one.
I’m unsure about how to truly “sync” the server and client in a performative way, so I’d love to hear some input about that or anything in general related to these solutions. Thanks!