operations method
Returns the Operations required by this consumer to compute its state.
The Operations on top of the snapshot blob, in the order they were applied: the ones the snapshot carries for this handler, the ones after it, and the ones of the open transaction.
Implementation
List<Operation> operations() {
final changes = [
...?SnapshotRecords.unfoldedChangesFor(doc._lastSnapshot, id),
...doc.changesForHandler(id, fromVersionVector: _snapshotVersionVector()),
].sorted(inplace: true);
// The list is sorted, so its last entry is the newest change the caller is
// about to fold in. See [CacheableStateProvider._noteReplayBoundary].
_noteReplayBoundary(changes.isEmpty ? null : changes.last);
final operations = <Operation>[];
for (final change in changes) {
final operation = _operationFromChange(change);
if (operation != null) {
operations.add(operation);
}
}
final uncommitted = doc._uncommittedOperations(id);
if (uncommitted.isEmpty) {
return operations;
}
// Their changes are only created at the commit, so the boundary is not
// known until then.
_replayBoundaryMatchesState = false;
return operations
..addAll(uncommitted)
..sort((a, b) => a.stamp!.compareTo(b.stamp!));
}