loading...

re: Single source of truth, how good/bad can it be? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Firstly, single source of truth does not mean storing everything in one object. It means that a single element of data is not stored in more than o...
 

Ok, it seems like I misunderstood some of the things you wrote. I have to say that I don't do a lot of front end development with Javascript.

It certainly is not a good idea to store a property that is used by multiple components in each of the component objects. But is it really the only alternative to store all of these properties in a single giant object? Can't you classify or group the properties somehow and create an object for each of these classes?

  • This will make the objects smaller and easier to handle.

  • It will also allow you to assign meaningful names to them and make the code more readable.

  • You will probably not use each property in each component. So splitting them up will also reduce the amount of dependencies.

But is it really the only alternative to store all of these properties in a single giant object?

It's the only one I can think of.

What I want is to remove all the state from every component.
So I can write my components like this.

function SomeView(state, actions) {
  // optionally some setup step... but not too much

  return // awesome stuff
}

For the state management could be a pattern like the ones described in here or here, or any other suggestion. Those are not exactly what I want but they are really close.

Code of Conduct Report abuse