I'm building a timer app that is available on mult...
# off-topic
z
I'm building a timer app that is available on multiple platforms, and the timer ticks down. I want it to sync between all the available platforms
s
One way of doing this would be to create a row which contains start time and stop time (both including timezone), and an ID to uniquely identify it. From there, you'd calculate the difference between the current time against the start time (taking into account the local timezone) and then format it as a duration. You might want to use realtime subscriptions so that when a timer starts or stops, this information is sent to all devices currently listening (and use RLS policies to prevent users from accessing timers they shouldn't have access to). That way, you're only ever dealing with small amounts of traffic which is good for server and your app performance. As long as the device clock is relatively accurate, the timer will also be accurate.
j
this sounds interesting 😄
z
Thanks that sound similar to what I was thinking. I'd have a property like
isPlaying
that would sync through Supabase, and then each client would know the other details like when the client should start and stop and then update. I'm actually using a
jsonb
field to make it NoSQL like in Postgres, and I'm updating the entire field with new info which might not be best, should I put this type of
isPlaying
info into a new row/column?
If anyone wants to help me with paid help I'm able to do that, might work better to talk over voice