DEV Community

Discussion on: Describe Your NgRx Actions More To Write Less Code

Collapse
 
martinsotirov profile image
Martin Sotirov

It's an interesting idea but I think it's better to have actions that are extremely granular. Why would a "FetchBlogPosts" action for example know anything about loading state or error messages? Those are a responsibility of the consuming service or component that dispatches the "FetchBlogPosts" action.

In my apps when I use a store solution (be it Vuex, ngxs or NgRx) I usually have a global store containing a loading flag and error messages, and then the individual feature stores know nothing about those. In my mind it is the consuming component's responsibility to set the loading flag (or better yet just intercept http requests in your router).