Store<S> constructor
Store<S> ({})
Implementation
Store({
required this.reducer,
required this.initialState,
this.modules = const []
}) {
if(initialState != null)
_stateChannel.send(StateAction(initialState, null));
channel = _stateChannel.asStream();
_dispatcher = modules.reversed.fold<Dispatcher>(
(action) async => _stateChannel.send(
StateAction(
await reducer(action, _stateChannel.valueOrNull()?.state ?? initialState),
action
)
),
(previousDispatcher, nextModule) => nextModule(
_dispatchRoot,
(registrar) => _registerInitialValueForModule(nextModule, registrar(this.initialState)),
_stateChannel,
previousDispatcher
)
);
dispatch(MeowChannelInit());
}