runInAction<T> function

T runInAction<T>(
  1. T fn(), {
  2. String? name,
  3. ReactiveContext? context,
})

Executes the mutation function fn within an Action. This ensures that all change notifications are fired only at the end of the Action block. Note that actions can be nested, in which case the notifications go out when the outermost Action completes.

Giving a name makes it easier to identify this action during debugging. You can also run this in a custom context. By default the mainContext will be used.

Implementation

T runInAction<T>(T Function() fn, {String? name, ReactiveContext? context}) =>
    Action(fn, name: name, context: context)() as T;