DEV Community

Discussion on: Creating a Data Store in Angular

Collapse
 
evgeniypp profile image
Eugene Petryankin

As for the pattern, it's just overengineering.

Simple and basic RxJS provides everything you need with much less code (StackBlitz Example).

It provides a Single Source of Truth for the application's data and states.

You do not have Single Source of Truth, because it does not mean that you have one class to handle the data, it means you have one immutable object with all the actual data in it.

It centralizes the process of triggering actions.

With basic RxJS you do not even need actions, you just call service methods.

It allows for a location for "global" functionality.

So can every providedIn: 'root' service

It provides a central location for all components and services to see data and state changes.

Putting everything in one class is not a central location and it will quickly become hard to use.

Collapse
 
rfornal profile image
bob.ts

I’m glad you enjoyed the article!

Collapse
 
rfornal profile image
bob.ts

FYI … pretty sure I explained it’s an exercise. Think a of this as an academic exercise in what “could” be done. For me, it provided a better understanding of all the tooling involved and pulled together some ideas in a way that made some concepts clearer.