WithReducers (access to Store or possible to Inject Services)? #4823
dreamstar-enterprises
started this conversation in
General
Replies: 1 comment 3 replies
-
That's by design. reducers should be pure functions. No async tasks, no access to DI or similar. So you should add all the necessary information for the reducer to the event when it is dispatched. That could be done by an effect for example Logging is actually a cross-cutting concern. You could also inject the events service in a service and listen to all events separately. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I try to use reducers to change the state of a store, with a full state change or a partial.
Using WithReducers, though, I cannot access props from the store (where I originally injected services).
I also cannot inject services in the 'on' method, as I get a DI error.
For example, here I simple cannot use any logging service:
Do I have to use WithEffects, or is it possible with a Reducer?
Beta Was this translation helpful? Give feedback.
All reactions