ModuleTree<S, R>
See original GitHub issueWhat problem does this feature solve?
This interface might help when dealing with nested modules on stores using Typescript.
Currently the Module<S, R>
interface exposes a single `ModuleTree<R>´ which allows us to create one level of nested modules.
Exposing a ModuleTree<R>
or a ModuleTree<S, R>
would be inline with the current GetterTree<S, R>
and other Trees and allow us to deeper nest our Modules.
I ran into this issue when attempting to create a nested module within a nested module using Typescript. The “parent” modules holds state for some supported features on the application and its children require to check those features in order to validate their actions
. The root state (or parent of the parent, in this case) simply holds environment and version information.
What does the proposed API look like?
I belive that a new interface ModuleTree<S,R>
might solve the issue:
export interface ModuleTree<S, R> {
[key: string]: Module<S, R>;
}
Which could be added to the Current Module<S, R>
interface as an or
:
export interface Module<S, R> {
namespaced?: boolean;
state?: S | (() => S);
getters?: GetterTree<S, R>;
actions?: ActionTree<S, R>;
mutations?: MutationTree<S>;
modules?: ModuleTree<R> | ModuleTree<S, R>;
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
@rodolphocastro Exactly! Both getters and actions, the rootGetters refers to the real “root” getter. Not the parents 👍
I think this issue is solved, so I’ll closing it. Thank you for your feedback! 🎉