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:action:) Default implementation

    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:action:) Default implementation

    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.

    Declaration

    Swift

    func reduceAny(state: State, action: Action) -> State

    Return Value

    A new immutable state

  • Undocumented

    Declaration

    Swift

    @inlinable
    public func callAsFunction(state: State, action: Action) -> State