You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking through the notes/documentation and I want to create a nested reducer for a complex application. I would like to have the actions split into separate, maintainable files for easier organization. I see in the docs for the NestedReducerBuilder you allude to BasActionNames and ChildActionNames, but I don't see how they all get connected together as your Store is created with something like
final store =newStore<AppState, AppStateBuilder, AppActions>(
appStateReducerBuilder.build(),
newAppState(),
newAppActions(),
middleware: []
);
which only includes the AppActions.
The text was updated successfully, but these errors were encountered:
Shoot, yea those docs are missing some context around the actions. In the example you are alluding to consider ChildActions and BaseActions to be defined as so:
// BaseActions is the main action class that contains// all actions for your store. It is passed to the store at// instantiation. It contains an action dispatcher and a reference// to an instance of ChildActions.abstractclassBaseActionsextendsReduxActions {
BaseActions._();
factoryBaseActions() =>new_$BaseActions();
ActionDispatcher<Null> get baseAction;
ChildActionsget child;
}
// ChildActions contains an action dispatcherabstractclassChildActionsextendsReduxActions {
ChildActions._();
factoryChildActions() =>new_$ChildActions();
ActionDispatcher<Null> get childAction;
}
As you can see, ChildActions is actually a field on BaseActions, meaning those child actions can be dispatched given an instance of BaseActions itself.
final store =newStore<AppState, AppStateBuilder, AppActions>(
appStateReducerBuilder.build(),
newAppState(),
newBaseActions(),
middleware: []
);
store.actions.baseAction();
store.actions.child.childAction();
The ActionNames classes are defined separately for BaseActions and ChildActions, and do not have references to each other at all.
Interesting... so when you use ActionNames in your examples the code still knows how to access that name despite not having a relationship established?
I was looking through the notes/documentation and I want to create a nested reducer for a complex application. I would like to have the actions split into separate, maintainable files for easier organization. I see in the docs for the NestedReducerBuilder you allude to BasActionNames and ChildActionNames, but I don't see how they all get connected together as your
Store
is created with something likewhich only includes the
AppActions
.The text was updated successfully, but these errors were encountered: