TestStore<State, Action, Environment> constructor

TestStore<State, Action, Environment>(
  1. State initialState,
  2. Reducer<State, Action, Environment> reducer,
  3. Environment environment, {
  4. bool skipInitialState = false,
})

Creates a test store with the given initialState, reducer, and environment.

If skipInitialState is true, the initial state is not recorded in states.

Implementation

TestStore(
  State initialState,
  Reducer<State, Action, Environment> reducer,
  Environment environment, {
  bool skipInitialState = false,
}) {
  _store = Store.initial(
    initialState,
    Reducer<State, Action, Environment>(
      reduce: (state, action, env) {
        actions.add(action);
        return reducer.reduce(state, action, env);
      },
    ),
    environment,
  );
  _store.stateObservable.listen((e) => states.add(e), fireImmediately: !skipInitialState);
}