Reducer
public protocol Reducer
Performs an action on a given state and returns a whole new version.
A store is given a single root Reducer
. As it’s sent actions, it runs the reducer to
update the application’s state.
-
The type of state that the
Reducer
is able to mutate.Declaration
Swift
associatedtype State
-
The supported actions of a reducer.
Declaration
Swift
associatedtype ReducerAction
-
reduce(state:
Default implementationaction: ) Operates on the state with the reducer’s own actions, returning a fresh new copy of the state.
Default Implementation
Default implementation. Returns the state without modifying it.
Declaration
Swift
func reduce(state: State, action: ReducerAction) -> State
Return Value
A new immutable state.
-
reduceAny(state:
Default implementationaction: ) Send any kind of action to a reducer. The recuder will determine what it can do with the action.
Default Implementation
Send any kind of action to a reducer. The recuder will determine what it can do with the action.
Return Value
A new immutable state
-
callAsFunction(state:
Extension methodaction: )