0001 /** 0002 This protocol is used when you want to make modifications to the store's state. 0003 All changes to the store go through this type. 0004 0005 Sample Action: 0006 0007 ```swift 0008 struct UpdateIdAction: ActionType { 0009 let id: Int 0010 0011 func reduce(state: AppState) -> AppState { 0012 state.id.value = id 0013 return state 0014 } 0015 } 0016 0017 store.dispatch(UpdateIdAction(id: 1)) 0018 ``` 0019 */ 0020 public protocol ActionType{ 0021 /** 0022 The type of the app's state. 0023 0024 - note: This is inferred from the `reduce` method implementation. 0025 */ 0026 typealias StateValueType
Store.swift:39 mutating func dispatch<Action: ActionType where Action.StateValueType == ObservableState.ValueType>(action: Action)Store.swift:53 public mutating func dispatch<Action: ActionType where Action.StateValueType == ObservableState.ValueType>(action: Action) {0027 0028 /** 0029 This method is called when this action is dispatched. Its purpose is to 0030 make modifications to the state and return a new version of it. 0031 0032 - note: This is the only place that changes to the state are permitted. 0033 - parameter state: The current state of the store. 0034 - returns: The new state. 0035 */ 0036 func reduce
Action.swift:36 func reduce(state: StateValueType) -> StateValueTypeAction.swift:36 func reduce(state: StateValueType) -> StateValueTypeStore.swift:39 mutating func dispatch<Action: ActionType where Action.StateValueType == ObservableState.ValueType>(action: Action)Store.swift:53 public mutating func dispatch<Action: ActionType where Action.StateValueType == ObservableState.ValueType>(action: Action) {(state: StateValueType) -> StateValueType 0037 } 0038
Store.swift:54 state.value = action.reduce(state.value)