Skip to content

Set currentUser dependency value for child reducer #2825

Answered by mbrandonw
shredlocker asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @shredlocker, your dependency can hold onto mutable data and you can mutate it though a dependency endpoint. This is how we handle things in the APIClient in isowords:

https://github.com/pointfreeco/isowords/blob/595afc1a425e490f078a7b6e1d4ce6e6f28a56b6/Sources/ApiClient/Client.swift#L7-L15

The authenticate endpoint mutates some internal data to represent the current user, and logout clears out that data.

I think that is typically a better approach than ReducerReader.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@shredlocker
Comment options

Answer selected by shredlocker
Comment options

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