transaction<R> method
Future<R>
transaction<R>(
- Future<
R> body(- KeyStoreTxn<
String, AtNotification, dynamic> txn
- KeyStoreTxn<
override
Run body as a transaction. Mutations performed via the
supplied handle are buffered in memory and applied in body
order on successful completion; if the body throws, the
buffer is dropped and the exception propagates.
Hive impls provide best-effort atomicity; a future SQL impl will provide true atomicity.
Implementation
@override
Future<R> transaction<R>(
Future<R> Function(KeyStoreTxn<String, AtNotification, dynamic> txn) body,
) async {
final txn = _HiveAtNotificationKeystoreTxn(this);
final R result;
try {
result = await body(txn);
} catch (_) {
rethrow;
}
for (final op in txn._ops.values) {
await op.apply(this);
}
return result;
}