I must be a bit dense on this little Sunday morning but I don't quite get the problem solved.
Is it an issue with reactivity between browser tabs? Hence the use of the Broadcast Channel API?
The reactivity being implemented in svelte, what is different from any normal app? could have been react with mobx, zustand, recoil, etc but that's not too relevant. This is just how frontend frameworks are nowadays.
Especially since it is single-user (player? sic)?
Syncing between the backend server (remote state) and the local sqlite instance (local state) shouldn't really require much work? A simple websocket connection could do the trick to push from the remote server to the local device and then push the changes to sqlite again. But that's not too surprising to me.
I must not have understood something...
There’s a whole world of syncing databases when they’re offline and then reconnect. Local first. If your websocket connection is offline you have to store the incremental changes to your data and send them later on reconnect. This gets complex fast.
A lot of these tools (and what the author wrote) offer toolkits to do this well, not having to implement and track all these changes in state manually.
In this case the author is running SQLite in the browser, and that syncs to SQLite on the server.
oh ok. What does it require? CRDTs?
Among other things, but even with a “latest change wins” method you still have to make sure all transactions arrive, data doesn’t stay out of synch forever, and other challenges.
ElectricSql, instantdb, rxdb, jazz.tools, are some of the things I’ve been looking into to make these tasks easier.