DEV Community

Discussion on: Who's looking for open source contributors? (May 29 edition)

Collapse
 
bgadrian profile image
Adrian B.G.

Sorry to bother, but isn't the fact that you bring all the stores into a global entity brakes the entire purpose of modules in the first place?

Beside the obvious reasons (global and singleton are bad), the box it is a single point of failure, how can you do the tests of a view (you can inject a module or you have to inject a box and a module?).

Collapse
 
anishkumar profile image
Anish Kumar • Edited

Hey Adrian,
Thanks for asking. Redux box uses redux under the hood, as implied by the name itself. So it adheres to all the principles that redux is based upon, the 'single store' being one of them. However, redux doesn't force you to implement your whole store as a single module or single reducer. It's possible to organize your store in the modular fashion, which offers some great advantages:

1) Expressive and organized codebase - For example, you can split your giant e-commerce logic in separate modules like profileModule, searchModule, orderModule, historyModule etc. It just makes a lot more sense than organizing files by types.

2) When you get an error in your actions/sagas/mutations you can figure out the module in the error stack trace.

3) It makes code reusability across platforms easier. For example, if there's module (say profileModule) to be used across web and mobile app, you can use the same module in two apps without any change.

Apart from modularity redux-box offers some other features, like handling immutability (so you can use push, pop, etc in your reducers without causing any side effects), it makes the whole store setup process a breeze, you literally set up the store for your application in less than 10 lines of code etc.