Immutable state

Now you might be wondering why we are always going with Immutable data. Well, the answer is quite complex but also simple. It forces us to have a Uni-directional data flow. But what does that even mean?

This means that the state can ONLY be changed from within the controller and can not be mutated from outside the controller (except using methods on the controller). This is great because what this means is that whenever a state changes in a way we did not expect we can always trace it back to the controller or a method used from it.

Comparing to using for example a mutable object, there could be cases it's mutated from outside the controller, meaning the state changes doesn't reflect in the UI/app which can result in some nasty hard to locate bugs.

This does not mean that a mutable state is bad by any means. But from my experience defaulting to using immutable data greatly simplifies the development long term!