Multiple store instances in a React Redux app
, I know it's not recommended but I think in my case they are.
I am doing an elevator logic app for a building with 2 elevators. When an elevator is requested on any floor selected, is the one that could arrive at the floor the earliest time (after going through all other called floors in its cue). I was thinking of having a main store of the building, which checks availability according to the above logic, and then adds the call to the selected elevator's cue.
Each elevator will have its own store for managing the elevator cue, for going, arriving and moving to the next floor in the cue.
Is this a good example for React Reudx subapps
/ substores
?
If you have exactly two elevators, you can have a store shape like
And then you can use the same reducer for each elevator. Even with n elevators you can create a state that takes the form of
So, to answer your question, no I don't think having multiple stores is necessary.