Search code examples
angularjsreduxcomponentsangular-redux

Redux store should be one for each module or one for whole application comprising of a multiple mudules


I am integrating or sort of rewriting my Angular 1 application with Redux. It has the following architecture:

app1 => App1 running on diff subdomain app2 => App2 running on diff subdomain and so on... shared => Shared modules(with multiple components) b/w app1 and app2

An app is made of multiple modules specific to it.
Shared directory has one or many modules that are shared between two or more apps

So my question is should I have app level store or a module level store.

By app level store and module level store I mean, for example:

  1. Let's say we have a shared module SM1 which is shared between two apps.
  2. SM1 should use the store of app1 when used inside app1 and should use the store of app2 when used inside app2. But a module should be a self-sustained entity and it should not rely on any other thing for its store.
  3. Or the SM1 could have its own store not sharing with any app. But when the SM1 is used inside app1 will its store conflict with the store of app1.
  4. Also if I use a module level store then the module and the app both need to be provided with the ngRedux dependencies which seem kind of redundant.

What is the best solution here in terms of a scalable architecture and redux core principles?


Solution

  • I would go for loose coupling as much as you can:

    • app1 - own store (integrates sm store)
    • app2 - own store (integrates sm store)
    • sm - own store