DEV Community

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

Michael De Abreu on March 03, 2018

Hi there! Long time no see. I'm been kind of busy setting my blog, I'm sorry. I made the UI from the ground, because I didn't like any of the theme...
Collapse
 
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?

Collapse
 
michaeljota profile image
Michael De Abreu

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:
ngrx-ducks#interfaces.

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.