transaction<T> function
During a transaction, no derivations (Reaction or Computed) will be run and will be deferred until the end of the transaction (batch). Transactions can be nested, in which case, no derivation will be run until the top-most batch completes
Implementation
T transaction<T>(T Function() fn, {ReactiveContext? context}) {
final ctx = context ?? mainContext
..startBatch();
try {
return fn();
} finally {
ctx.endBatch();
}
}