In the last days I have searched for a documentation on how and when is it best to use redux and how to design the state tree.

My research ended in the conclusion that there is no one correct answer. Then I came across this answer in github on that manner by petehunt (The answer is intended for flux). He's answer is almost unambiguous:

I think the use of flux is justified when two conditions are met:

  1. You have a piece of data that needs to be used in multiple places in your app, and passing it via props makes your components break the single-responsibility principle (i.e. makes their interface make less sense)
  2. There are multiple independent actors (generally, the server and the end-user) that may mutate that data.

My poor knowledge on the subject gave me hard time to understand why the first condition is related to the question.

Please share your opinion about this and if it is possible, relate your answer to the following example:

A simple app that has a login component and show-profile-details component. My app will talk to a server for the login functionality.

The simplest way to design the state tree would be by:

      connectedUser: {
        connectedUserID:String (There could be much more details here)
      serverStatus: String (connected/connecting/disconnected),
      languageID: String

The problem is that every design will break the single source of truth. For example, one could store the status of the login (fail,loading,success),the number of login tries,the profile being displayed right now. The point is that this list will never be over and in one way or another, some data will be stored in the component!

How could one know what is best to put in the state tree and what to keep in the login component and export it to other components?

Some extra details and requests:

  1. I'm developing in Angular2 (There is no tag for Angular2)
  2. Please share your sources of your answers if they are exists.


  • Single Source of Truth is not a mandate; it is a guideline. The point of SST is to have a definitive arbiter of the truth, not to prevent information from ever spreading through a system. Sep 8, 2016 at 22:15
  • Thanks for the quick reply Robert Harvey. Does one of the reasons related to what I indicated?
    – Stav Alfi
    Sep 8, 2016 at 22:19
  • One of the reasons for what, to what you indicated where? Sep 8, 2016 at 22:21
  • Sory for any confusion, I'm guessing that one of the reasons is we just can't store all the component properties inside the state tree. My question is how do we desice which should be inside the state tree.
    – Stav Alfi
    Sep 8, 2016 at 22:31
  • 1
    Store what you need. There really isn't any better answer than that. Over time, as the application evolves, you may find that you have to force your users to conform to an interface to manage the change. You may eventually require users to look up certain things in a database (your single source of truth). But nobody is clairvoyant enough to figure out everything they need ahead of time. Use your best judgement, and evolve the object as your needs change. Sep 8, 2016 at 22:36


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.