Probably a bit specific and technical (so I’ll probably try Stack Overflow too), but hopefully we’ve got some front end engineers up in here!
I discovered redux a while back, and was frankly always scared of functional programming. Bad Kinthalis! Ever since I’ve started to dabble however, I’ve seen nothign but benefits when dealing with managing complex application state.
My current data structure is pretty much verbatim what you see in something like the ngrx/store example app: https://github.com/ngrx/example-app.
I’ve got an action class for a particular slice of my store - this is traditional, injectable angular 2 service (one of only three the other being the effects operations for the store), which contains and exposes all the actions for a particular store for the app to consume.
I’ve got an effects class for handling http or other setup/tear down logic or side effects required as part of the action, or to manage a set of actions that must flow from one to the other.
And finally I’ve got my reducer functions, also an injectable that, along with my effects, get’s bootstrapped into my app module.
Now, when I was doing MVC I would wire everything up via services. Each component had at least one service that provided some functionality or data to it for display. But with redux, I find that I’m creating pure typescript classes or static utility functions that are called as either part of the action creator or as part of the effects operation. Since I’m importing these classes there, they aren’t injectable and and completely decoupled from the angular 2 framework.
I think this is the right way of doing redux. But I can’t shake some feeling that I’m doing something wrong. The only ng2 services in my app are just the three foundations of the redux pattern (well, those three times each store slice), I’m not creating or using ng services anywhere else.
Is this a natural byproduct of the pattern? I haven’t read anywhere or seen anyone flat out say: yeah, now you don’t need services anymore! Seems like something I’d mention at some point, somewhere in my lecture/tutorial.