waitFor<S extends EffectCommandState<A, E>> method

Future<S> waitFor<S extends EffectCommandState<A, E>>({
  1. bool where(
    1. S state
    )?,
  2. Duration timeout = const Duration(seconds: 5),
})

Wait for the current or next state assignable to S.

Implementation

Future<S> waitFor<S extends EffectCommandState<A, E>>({
  bool Function(S state)? where,
  Duration timeout = const Duration(seconds: 5),
}) async {
  final state = await waitUntil(
    (state) => state is S && (where?.call(state) ?? true),
    timeout: timeout,
  );
  return state as S;
}