Skip to content
Discussion options

You must be logged in to vote

The parent should be responsible for that logic,
for example, in your Question reducer:

var body: some ReducerProtocol<State, Action> {
        Reduce { state, action in
            switch action {
            case .answer(let tappedID, action: .answerTapped):
                let correctAnswerID = state.questionData.correctAnswerID
                if tappedID == correctAnswerID { 
                    state.answers[id: tappedID].answerData.isCorrect = true
                } else { 
                    state.answers[id: correctAnswerID].answerData.isCorrect = true
                    state.answers[id: tappedID].answerData.isCorrect = false
                }
                state.answered = …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ammerzon
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