microsoft / redux-dynamic-modules

Modularize Redux by dynamically loading reducers and middlewares.

Home Page:https://redux-dynamic-modules.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Place in the store where dynamic module should be added

Stwosch opened this issue · comments

Hello,

I'm struggling with adding dynamic modules to the store in a certain place.

In my case, I'm adding modules where each module has specific GUID that is its id.
Here is the structure of my dynamic module.
const modules = [{ id, reducerMap: { [id]: combineReducers(reducers) } }]
In this case everything works fine, modules are attached to the store.

But I wouldn't like to place every dynamic loaded module in the root of the store.
I would like to place them in the specific place in the store e.g. 'dynamicModules' key in the store.
So I tried to do that in this way:
const modules = [{ id, reducerMap: { dynamicModules: combineReducers({ [id]: reducer }) } }]

But it isn't working, because library checks whether the same key already exists in the store, so it will add only the first dynamic module. So my question is - Is there a method where I can point in which place dynamic modules should be attached in the store?

I have the same requirement, @Stwosch did u find any solution for this ?