There are situations where the cleanest solution to a use-case seems to be a combination of NGRX and a service. Is this wise, or does it violate the 'single source of truth' principle of NGRX?
For example, if I am using NGRX to build a shopping app I might have a store which includes:
- An array of all products (objects) with name, product ID, cost etc.
- An array of product IDs (strings or numbers) for the subset of products currently in the shopping cart.
The cart component would likely use a selector which filters all products by product IDs in the cart, but what about other components that need to know when an item is removed?
An array of 'removed' items is not going to be stored in the state, so one approach is to listen for a 'REMOVE_ITEM' action, and then update a service with the product IDs of the removed items. Components can then subscribe to this service and take appropriate action.
Is this good practise? If not, what is the recommended approach?