DEV Community

Discussion on: Why you should consider using classes to declare the state of @ngrx/store

3zsforinsomnia profile image
Zachary Levine

I feel like I am not understanding some of the benefits here. It seems like syntactically it is nearly the same. I can see potential benefits if you wanted to put validation for setting properties in the class as then it is not in the reducer, or more cleanly handling multiple properties changing due to one action. I personally tend to do that either before actions are dispatched or in "conditional" actions themselves, as an alternative mechanism for keeping the reducer itself simple. Not sure how I would combine the two approaches myself, but I can easily see others making use of this pattern.

Thoughts on other benefits or use cases?

michaeljota profile image
Michael De Abreu Author

Sorry for the delay answering this. I made another post talking about this, and a style guide proposal. I answer what you are asking here:

This is a personal opinion, but when you see the code, you see the benefits of using this approach.

Thanks you so much for your feedback, and I hope you like the proposal.