Skip to content

The best way to change reducer's environment dynamically #759

Answered by tgrapperon
satanworker asked this question in Q&A
Discussion options

You must be logged in to vote

I would recommend not mutating the environment in the reducer, like you do for credentialStorage. You don't have an error at this line because credentialStorage 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 with encryptNewPassword without getting back into the reducer. In other words, try to move the two lines involving the …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by satanworker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants