1
votes

I have an auth reducer that handles the following Actions: Login, Register, Logout, UserLoaded. And my AuthState contains the current logged in user. The user model has a devices property (Devices[]). Now I have an Action to activate a device, which triggers an Effect (ActivateDevice) that in turn triggers a state change in the devices array. Now I am not sure where to place all the NGRX related code (ActivateDevice action, Device Activated reducer function) that has to do with devices. I think this code doesn't really fit in the Auth Feature.

So should I just put the reducer to my authReducer and the ActivateDevice-Action to the Auth Actions or would you create distinct files (e.g. device.reducer.ts/device.actions.ts)? And if you created a different reducer. How is it then possible to handle the AuthState from this reducer?

1

1 Answers

0
votes

If they are two separate entities, I would suggest splitting them up in to multiple reducers. I don't know enough to say this is the way to go for your problem, because in some cases it's easier to "group" entities in a single reducer.

How is it then possible to handle the AuthState from this reducer

It can't. A reducer is only responsible for its own state, and can't access/modify state from another reducer.