recordOptimisticTransaction method

void recordOptimisticTransaction(
  1. CacheTransaction transaction,
  2. String addId
)

Record the given transaction into a patch with the id addId

1 level of hierarchical optimism is supported:

  • if a patch has the id $queryId.child, it will be removed with $queryId
  • if the update somehow fails to complete before the root response is removed, It will still be called, but the result will not be added.

This allows for multiple optimistic treatments of a query, without having to tightly couple optimistic changes

Implementation

void recordOptimisticTransaction(
  CacheTransaction transaction,
  String addId,
) {
  inflightOptimisticTransactions += 1;
  final _proxy = transaction(OptimisticProxy(this)) as OptimisticProxy;
  if (_safeToAdd(addId)) {
    optimisticPatches.add(_proxy.asPatch(addId));
    broadcastRequested = broadcastRequested || _proxy.broadcastRequested;
  }
  inflightOptimisticTransactions -= 1;
}