When writing server code without using the Jazz HTTP wrapper, one of the pain points is to use waitForSync
We could give a better experience writing an higher level API to do this
const worker = await getJazzWorker();
const node = worker._raw.core.node;
const tracking = node.syncManager.trackDirtyCoValues();
// [...] business logic
// For each CoValue changed during this invocation, ensure it has been synced.
await Promise.all(
Array.from(tracking.done(), (id) => node.syncManager.waitForSync(id)),
);
Proposal:
const changes = Account.trackChangedCoValues(worker);
// [...] business logic
await changes.stopTracking().waitForSync();