Search code examples
angularreduxfluxngrx

Redux - Single immutable state. Per app or per module?


I have a conception question about app based on Redux.

Preface

I'm at the design level my new Angular2 app. Basic function of app will be showing some datatables (but number of tables and datas will be dynamically). I assumed that I would create main AppModule and TableModule (used in main module). In creating the application I wanted to use Redux ang ngrx libraries.

I do not want to make mistakes at planning level. One thing that is bothering me:


Question:

Should the application (single, immutable) state be per application or per module?


Description:

I thing that isolation table to separate module is important because lot of my table's functionality. Is it correct to create a separate state for a module used in another module? Is this consistent with the basic assumption of Redux? (single state?) What threats will it cause?

Please feedback people who have experience with app based on Redux. Thanks a lot!


Solution

  • Redux it is designed to store all your state application in one single place, so called the store which holds the whole state tree of your application.

    A single store could be added in a separate module if you prefer too but there is only a single state tree in the application.

    You could organize the state tree keeping the concept of table as you mention in your question.

    I suggest you to have a look at some suggestions on state organization and example from this redux doc: Normalizing State Shape.