Just a question (and to surface the consideration because I was staring at it):
Example scenarios:
- a transaction updates two query collections
- a transaction updates two electric collections
- a transaction updates a query collection and an electric collection
The mutation function can:
await collection.invalidate() for the query collection(s); and
await collection.awaitTxId(txid) for the electric collections
Any of these may take a different amount of time to resolve.
I assume the safe default would be to wait for all collections to be updated. Otherwise you risk flickering if you discard optimistic state before the collection has caught up.
However, I also wonder if there might be a mechanism for different collections to discard their state individually following a single transaction? Such as returning a {collection: promise, ...} value from the mutationFn? I don't know is this is desirable or not but the status quo is either:
- Promise.all() => wait longer than needed to discard local state if one of your collections is slow
- Promise.race() => risk of flickering if you discard before all collections have synced
Yeah a collection won't commit any synced data until a persisting transaction is finished. Which yes means a slow collection will hold it up.
Allowing people to opt into commiting server state for some collections independently of others makes sense but I'd want to see how common this is a problem first.