The best way to change reducer's environment dynamically #759
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
sorry for posting the same screenshot twice |
Beta Was this translation helpful? Give feedback.
-
I would recommend not mutating the environment in the reducer, like you do for Ideally, your reducer only mutates the state and produce effects. These effects can involve the environment, of course, and you can also produce effects that will mutate the environment. In your case, I would wrap your client inside another "meta" client that is configurable. When you receive
Your meta |
Beta Was this translation helpful? Give feedback.
I would recommend not mutating the environment in the reducer, like you do for
credentialStorage
. You don't have an error at this line becausecredentialStorage
is most likely a class.Ideally, your reducer only mutates the state and produce effects. These effects can involve the environment, of course, and you can also produce effects that will mutate the environment.
In your case, I would wrap your client inside another "meta" client that is configurable. When you receive
createNewPassword
, you emit some effect configuring the "meta" client. You can even chain directly withencryptNewPassword
without getting back into the reducer. In other words, try to move the two lines involving the …