createStore function
- {List<
StateBase> states, - List<
EffectBase> effects, - bool exposeApiGlobally: false}
This is the entry point of the ajwah store.
states
is a mandatory param. And it should not be null or empty.
effects
is an optional param.
exposeApiGlobally
by default it is false
. If you pass true
then global
functions like dispatch(), select() etc should be exposed.
Also you can dynamically add or remove state and effect using addState(BaseState stateInstance) ,removeStateByStateName(String stateName), addEffects(BaseEffect effectInstance), addEffect(EffectCallback callback, {@required String key}), removeEffectsByKey(String key)
Implementation
Store createStore({
List<StateBase> states,
List<EffectBase> effects,
bool exposeApiGlobally = false,
}) {
var store = Store(states ?? []);
(effects ?? []).forEach((effect) {
store.addEffects(effect);
});
if (exposeApiGlobally) {
_store = store;
}
return store;
}