microsoft / redux-dynamic-modules

Modularize Redux by dynamically loading reducers and middlewares.
https://redux-dynamic-modules.js.org
MIT License
1.07k stars 116 forks source link

Place in the store where dynamic module should be added #143

Open Stwosch opened 4 years ago

Stwosch commented 4 years ago

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?

sanchitbansal10 commented 3 years ago

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