1
votes

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 !

1
are you available in teamviewer? - Aravind
why you need teamviewer ? - May
thanks for your offer, but i just need general guidance as for best practice... - May
Sure. but your post to broad. - Aravind
i tried to be clear. on q1: do you introduce the store to your component , or using a facade - May

1 Answers

1
votes

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