setState abstract method

Future<T?> setState(
  1. Object? mutator(
    1. T s
    ), {
  2. SideEffects<T>? sideEffects,
  3. StateInterceptor<T>? stateInterceptor,
  4. bool shouldOverrideDefaultSideEffects(
    1. SnapState<T> snap
    )?,
  5. int debounceDelay = 0,
  6. int throttleDelay = 0,
})

Mutate the state of the model and notify observers.

  • Required parameters:
  • The mutation function. It takes the current state fo the model. The function can have any type of return including Future and Stream.
  • Optional parameters:
  • sideEffects: Used to handle side effects resulting from calling this method. It takes SideEffects object. Notice that SideEffects.initState and SideEffects.dispose are never called here.
  • shouldOverrideDefaultSideEffects: used to decide when to override the default side effects defined in RM.inject and other equivalent methods.
  • debounceDelay: time in milliseconds to debounce the execution of setState.
  • throttleDelay: time in milliseconds to throttle the execution of setState.

Implementation

Future<T?> setState(
  Object? Function(T s) mutator, {
  SideEffects<T>? sideEffects,
  StateInterceptor<T>? stateInterceptor,
  bool Function(SnapState<T> snap)? shouldOverrideDefaultSideEffects,
  int debounceDelay = 0,
  int throttleDelay = 0,
});