updateInTransaction method
Executes a state update within a transaction.
This creates a new transaction, applies the update, and commits it. If any error occurs, the transaction is automatically rolled back.
Implementation
Future<void> updateInTransaction(void Function() update) async {
final manager = TransactionManager();
await manager.executeInTransaction((transaction) async {
if (this is TransactionalStateMixin<T>) {
(this as TransactionalStateMixin<T>).joinTransaction(transaction);
} else {
transaction.addState(this);
}
update();
});
}