0

I am creating an application with different types of user and each one with its respective login page. The thing is that when the user logs in as 'typeUserA' in my general Redux store, data is saved that is specific to type A users, and in turn, if the user logs in as 'typeUserB' in another tab, this updates the general Redux store with typeUserB information. This way, if I go back to tab 1 and refresh the page, the typeUserA information is replaced by a typeUserB, which is logical since it was updated in the login of typeUserB.

My question regarding this is, is there any way to have multiple isolated stores in relation to the multiple sessions that my application can have active? I mean: in the active session of typeUserA have the typeUserAStore, in the session of typeUserB have the typeUserBStore, so that they are not stepped on. Taking into account that the requirement of the application itself marks that there can be more than one active session in the browser and there could be more than 2 user types (not only A and B).

As i read, there is a way to dynamically add reducers with replaceReducers, but so far I haven't been able to get this to work.

  • 1
    I feel like in general what you are trying to do is having multiple stores in redux. This is something that's not usually done, check here https://stackoverflow.com/a/33633850/3668241. What I'd recommend is to build the data structure of your redux store in a way that it fulfils your requirements in a single store. For example, the objects you store could have a user id, and you get the data from the store by user id. – hannojg May 31 '22 at 18:52

0 Answers0