i'm trying to learn redux and i'm not sure what is best way to structure my app state when the app is used by multiple users.
App flow:
on every login {userid,username,token}
is stored in localStorage.appUsers
now if my app initialState looks like following
{
appusers:[],//Array of app users, i only keep the token and id and username and i fetch the full user info from server when user is selected as current logged in.
currentUser:{id,fullname,picture,...etc} //current user
blog:[],//array of blog posts of current logged in user
chat:[],//array of chat messages of current logged in user
}
i use localstorage also to save the user state so that next time he open app, it present initialState from localstorage until it refresh the cache from server.
problem is that currently the blog and chat keeps array of posts for the current logged in user, when user switch users he is presented with someone else data.
so what is the correct approach to maintain separate store for every user ? i tried to modify my initial state so that the blog and chat arrays become a property of appUsers, then i faced problem with react combineReducers which expects a key for every reducer in the initialState.