Reducer

public struct Reducer<State>

A type which takes a State and Action returns a new State.

  • id

    An unique identifier used when registering/unregistering the Reducer on the Store.

    Declaration

    Swift

    public let id: String
  • A pure function which takes the a State and an Action and returns a new State.

    Declaration

    Swift

    public let reduce: (inout State, Action) -> Void
  • Creates a Reducer from a reduce function.

    The reduce function is a pure function which takes the a State and an Action and returns a new State.

    Declaration

    Swift

    public init(id: String = UUID().uuidString, reduce: @escaping (_ state: inout State, _ action: Action) -> Void)

    Parameters

    reduce

    The reduce function to create a Reducer from

    state

    The State to mutate

    action

    The Action dispatched

  • Creates a Reducer from a list of ReduceOns.

    Declaration

    Swift

    public init(id: String = UUID().uuidString, _ reduceOns: ReduceOn<State>...)

    Parameters

    reduceOns

    The ReduceOns which the created Reducer should contain