🟢 the first user won't get the update until they refresh the page
This is fine for most use-cases, but I think we can do a simple upgrade to make it more real-time.
Naive Real-time Approach
For example, a very simple and naive approach could be:
1️⃣ the client connects to the server via websockets (we already have this built)
2️⃣ every time an operation is invoked on the server, we send an update event e.g. { action: "addUser", entities: ["User"] } to the client
3️⃣ client then can invalidate it's local queries depending on the User entity
The Devil Is In the Details
This would make our clients "real-time", although, they would fetch a lot of data if we don't scope the events somehow (maybe by user or we give explicit control to the user what should be "realtime")
Our main issue (other than making sure events are published for updates) would be to figure out the scoping. This is something we should flesh out in an RFC before jumping on this task.
Using SSR instead of websockets (although I'd probably vote against it today, especially considering the fact we already have WS support)
Should live updates be the default option and should we keep the old system (i.e., local entity-based cache updates)? Most users probably wouldn't want to pay the "websocket cost" and are fine with only updating the actor's UI
Let's just see what we have now:
This is fine for most use-cases, but I think we can do a simple upgrade to make it more real-time.
Naive Real-time Approach
For example, a very simple and naive approach could be:
The Devil Is In the Details
This would make our clients "real-time", although, they would fetch a lot of data if we don't scope the events somehow (maybe by user or we give explicit control to the user what should be "realtime")
Our main issue (other than making sure events are published for updates) would be to figure out the scoping. This is something we should flesh out in an RFC before jumping on this task.
Existing Work
Supabase operates similarly https://supabase.com/docs/guides/realtime, and now I found that Directus does as well https://directus.io/toolkit/realtime