Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for nested reducers #160

Open
PhilippMelnikov opened this issue Oct 13, 2020 · 4 comments
Open

support for nested reducers #160

PhilippMelnikov opened this issue Oct 13, 2020 · 4 comments

Comments

@PhilippMelnikov
Copy link

Hello!
Does the library provide support for loading nested reducers? Suppose i have a store structure like this
{
auth,
me: {
counters,
orders
}
}

I want to load reducers for orders later. How do I do that?

@dzintars
Copy link

Mby this - https://redux-dynamic-modules.js.org/#/reference/Dependencies ?

@PhilippMelnikov
Copy link
Author

If we take example from docs you're suggesting, what would the final structure of the store look like?

@antokara
Copy link

import { combineReducers} from '@reduxjs/toolkit';

interface ICountersState {
  counters: number;
};

interface IOrdersState {
  orders: number;
};

interface IMeState {
  me: {
    counters: ICountersState;
    orders: IOrdersState;
  }
};

const counters = (state, action) => { // your reducer for counters };
const orders = (state, action) => { // your reducer for orders };

const meModule: IModule<IMeState> = {
  id: 'me',
  reducerMap: {
    me: combineReducers({ counters, orders })
  }
};

@PhilippMelnikov give it a try and let me know.
I think this should be added to the documentation because it is a very common use case.

@nkalinov
Copy link

nkalinov commented Jun 7, 2022

I just added support for this via lodash.set paths in this PR: #195
Looking at this repo's activity I do not expect it to be merged (soon) so if you want you can use it immediately with npm gh link: "redux-dynamic-modules": "https://github.com/nkalinov/redux-dynamic-modules.git"
That's what I'm going to do at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants