1

while implementing an ngrx/store solution, i'm creating smart/container component. i am reading some conflicting ideas in some blogs.

should the smart component inject the store ? or should i create a service that will be a facade, in the service will inject the store ?

While the idea of using a service to "hide" the store itself is nice, it seems that it make some code duplicate. for example, if in the component i need to dispatch an action "ADD_USER" i will call a function in the service named: addUserAction(user) and in the service, i will have a one liner function: store.dispatch({type: ADD_USER, payload: user})

thanks !

May
  • 240
  • 2
  • 10

1 Answers1

1

If your facade layer is just a thin wrapper over store.select then it's probably not worth the trouble. I would only introduce the facade layer when it needs to manage a bunch of services as explained here:

https://en.wikipedia.org/wiki/Facade_pattern

seescode
  • 2,101
  • 15
  • 31