rocicorp / replicache

Realtime Sync for Any Backend Stack
https://doc.replicache.dev
1.01k stars 37 forks source link

RFE: A way to know if/when at least one sync has happened #1045

Open aboodman opened 1 year ago

aboodman commented 1 year ago

People often want to know when the fist sync round trip has happened. One common reason for this is to initialize state with some default data. Waiting for onSync(true) sort of works except:

The simplest way I can think of to accomplish this is to add a promise like firstServerResponse: Promise<void>. If the client knows it has already had one server response, it can resolve this immediately, otherwise it can wait.