middleSetState method

dynamic middleSetState(
  1. StateStatus status,
  2. Object? result, {
  3. SideEffects<T>? sideEffects,
  4. StateInterceptor<T>? stateInterceptor,
  5. bool shouldOverrideDefaultSideEffects(
    1. SnapState<T>
    )?,
})

Implementation

middleSetState(
  StateStatus status,
  Object? result, {
  SideEffects<T>? sideEffects,
  StateInterceptor<T>? stateInterceptor,
  bool Function(SnapState<T>)? shouldOverrideDefaultSideEffects,
}) {
  if (status == StateStatus.isWaiting) {
    setToIsWaiting(
      sideEffects: sideEffects,
      shouldOverrideDefaultSideEffects: shouldOverrideDefaultSideEffects,
      stateInterceptor: stateInterceptor,
    );
    return;
  }
  if (status == StateStatus.hasError) {
    assert(result is SnapError);
    setToHasError(
      (result as SnapError).error,
      stackTrace: result.stackTrace,
      refresher: result.refresher,
      sideEffects: sideEffects,
      shouldOverrideDefaultSideEffects: shouldOverrideDefaultSideEffects,
      stateInterceptor: stateInterceptor,
    );
    return;
  }
  setToHasData(
    result,
    sideEffects: sideEffects,
    shouldOverrideDefaultSideEffects: shouldOverrideDefaultSideEffects,
    stateInterceptor: stateInterceptor,
  );
}