April 2017
Intermediate to advanced
316 pages
9h 33m
English
Actions are structs that conform to the ActionType protocol from the Delta library. ActionType is used when we want to make modifications to the store's State. All changes to the Store object go through this type. Let's examine one example:
import Delta struct UpdateTodoAction: ActionType { let todo: Todo func reduce(state: State) -> State { state.todos.value = state.todos.value.map { todo in guard todo == self.todo else { return todo } return Todo(todoId: todo.todoId, name: self.todo.name, description: self.todo.description, notes: self.todo.notes, completed: self.todo.completed, synced: !todo.synced, selected: todo.selected) } return state } }
In our manager, we had a call like this:
store.dispatch(UpdateTodoAction(todo: ...
Read now
Unlock full access