ReduceOn

public struct ReduceOn<State>

A part of a Reducer which only gets triggered on certain Actions or ActionTemplates.

  • 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 ReduceOn which only runs reduce with actions of the type specificed in actionType.

    Declaration

    Swift

    public init<A>(_ actionType: A.Type, reduce: @escaping (_ state: inout State, _ action: A) -> Void) where A : Action

    Parameters

    actionType

    The type of Action to filter on

    reduce

    A pure function which takes a State and an Action and returns a new State.

    state

    The State to mutate

    action

    The Action dispatched

  • Creates a ReduceOn which only runs reduce with actions created from the specificed ActionTemplates.

    Declaration

    Swift

    public init<Payload>(_ actionTemplates: ActionTemplate<Payload>...,
                         reduce: @escaping (_ state: inout State, _ action: AnonymousAction<Payload>) -> Void)

    Parameters

    actionTemplates

    The ActionTemplates to filter on

    reduce

    A pure function which takes a State and an Action and returns a new State.

    state

    The State to mutate

    action

    The Action dispatched