commit method
Future<void>
commit({
- Iterable<
OutboxEntry> upserts = const [], - Iterable<
String> removals = const [],
override
Atomically inserts or replaces upserts (matched by id) and deletes the
entries whose ids are in removals. Unknown ids in removals are
ignored.
Implementation
@override
Future<void> commit({
Iterable<OutboxEntry> upserts = const [],
Iterable<String> removals = const [],
}) {
final ups = upserts.toList();
final rms = removals.toList();
return _serialized(() async {
final next = Map.of(await _load());
for (final e in ups) {
next[e.id] = e;
}
rms.forEach(next.remove);
await _write(next);
_cache = next; // Only after the file is safely replaced.
});
}