jazz
jazz copied to clipboard
Expose sync status for CoValues
Currently, we have the waitForSync method to allow forcing a sync and resolving on success. However, there is no way to get the current sync status of a CoValue, or the last time it was successfully synced.
Ideally, we would have a reactive subscription to the sync state of the CoValue, which developers can use to build features in their apps (e.g. pending sync status indicators, information on last sync time, etc.)
References:
- https://discord.com/channels/1139617727565271160/1139621689882321009/1392503913059717242
- https://discord.com/channels/1139617727565271160/1139621689882321009/1391089821593632821
Are you imagining this would be implemented as...
- A subscription to the sync status for a specific peer
- A subscription to an array of statuses, one per peer
- A subscription to the "fully-sync'dness" of a covalue
Or all/none of the above? :)
@justinrosenthal
The idea is to have an high-level API that devs can use to check the sync state of a group of values.
e.g.
const isSynced = useIsCoSynced(Schema, id, {
resolve: {
nestedProp: true
}
})
const isConnected = useJazzConnectionState();
if (isSynced) return "synced"
if (isConnected) return "syncing"
return "not-synced"