UI does not update based on the updateOrAppend of my state.todos #1044
-
The Composable Architecture uses GitHub issues for bugs. For more general discussion and help, please use GitHub Discussions or the Swift forum first. Hi there! var todos: IdentifiedArrayOf<Todo> = [/**omitted**/]
// my reducer has the following action:
case let .todos(id: identity, action: .toggled):
guard var found = state.todos.filter({ $0.id == identity}).first else {
return .none
}
found.isChecked.toggle()
state.todos.updateOrAppend(found)
return .none
What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
@idelfonsog2 Can you include a small example so we can reproduce? Would need to see how your View is structured. |
Beta Was this translation helpful? Give feedback.
-
(NB: Pat already answered while posting this, but thought I would go ahead and post it for more information) Hi @idelfonsog2, there is a domain defined just for a single todo row, and it's the one responsible for flipping the boolean: swift-composable-architecture/Examples/Todos/Todos/Todo.swift Lines 20 to 22 in 97c3a49 Then the "todos" domain (i.e. the domain that handles an entire list of todos) layers on additional logic on top of the So, as Pat mentioned, with your code changes you are toggling the boolean twice. Once in the todo list domain and again in the todos domain. If you can explain more of what you are trying to explore in this demo app we might be able to answer some questions. |
Beta Was this translation helpful? Give feedback.
@idelfonsog2 Can you include a small example so we can reproduce? Would need to see how your View is structured.