Selector

public class Selector<State, Value> : SelectorProtocol

A type which takes a State and returns a Value from it.

Selectors can be based on other Selectors making it possible to select a combined Value.

  • id

    An unique identifier used when overriding the Selector on the MockStore.

    Declaration

    Swift

    public let id: UUID
  • Creates a Selector from a keyPath.

    Declaration

    Swift

    public convenience init(keyPath: KeyPath<State, Value>)

    Parameters

    keyPath

    The keyPath to create the Selector from

  • Creates a Selector from a projector closure.

    Declaration

    Swift

    public init(projector: @escaping (State) -> Value)

    Parameters

    projector

    The projector closure to create the Selector from

  • Declaration

    Swift

    public func map(_ state: State) -> Value
  • Creates a Selector from a Selector and a projector function.

    Declaration

    Swift

    static func with<S1>(_ selector1: S1,
                         projector: @escaping (S1.Value) -> Value)
        -> Selector1<State, S1, Value>

    Parameters

    selector1

    The first Selector

    projector

    The closure to pass the value from the Selector to

    Return Value

    A Selector from the given Selector and the projector function

  • Creates a Selector from a Selector and a KeyPath.

    Declaration

    Swift

    static func with<S1>(_ selector1: S1,
                         keyPath: KeyPath<S1.Value, Value>)
        -> Selector1<State, S1, Value>

    Parameters

    selector1

    The first Selector

    keyPath

    The KeyPath to subscript in the value from the Selector

    keyPath

    The KeyPath to subscript in the value from the Selector

    Return Value

    A Selector from the given Selector and the KeyPath

  • Creates a Selector from two Selectors and a projector function.

    Declaration

    Swift

    static func with<S1, S2>(_ selector1: S1,
                             _ selector2: S2,
                             projector: @escaping (S1.Value, S2.Value) -> Value)
        -> Selector2<State, S1, S2, Value>

    Parameters

    selector1

    The first Selector

    selector2

    The second Selector

    projector

    The closure to pass the values from the Selectors to

    Return Value

    A Selector from the given Selectors and the projector function

  • Creates a Selector from three Selectors and a projector function.

    Declaration

    Swift

    static func with<S1, S2, S3>(_ selector1: S1,
                                 _ selector2: S2,
                                 _ selector3: S3,
                                 projector: @escaping (S1.Value, S2.Value, S3.Value) -> Value)
        -> Selector3<State, S1, S2, S3, Value>

    Parameters

    selector1

    The first Selector

    selector2

    The second Selector

    selector3

    The third Selector

    projector

    The closure to pass the values from the Selectors to

    Return Value

    A Selector from the given Selectors and the projector function

  • Creates a Selector from four Selectors and a projector function.

    Declaration

    Swift

    static func with<S1, S2, S3, S4>(_ selector1: S1,
                                     _ selector2: S2,
                                     _ selector3: S3,
                                     _ selector4: S4,
                                     projector: @escaping (S1.Value, S2.Value, S3.Value, S4.Value) -> Value)
        -> Selector4<State, S1, S2, S3, S4, Value>

    Parameters

    selector1

    The first Selector

    selector2

    The second Selector

    selector3

    The third Selector

    selector4

    The fourth Selector

    projector

    The closure to pass the values from the Selectors to

    Return Value

    A Selector from the given Selectors and the projector function

  • Creates a Selector from five Selectors and a projector function.

    Declaration

    Swift

    static func with<S1, S2, S3, S4, S5>(_ selector1: S1,
                                         _ selector2: S2,
                                         _ selector3: S3,
                                         _ selector4: S4,
                                         _ selector5: S5,
                                         projector: @escaping (S1.Value, S2.Value, S3.Value,
                                                               S4.Value, S5.Value) -> Value)
        -> Selector5<State, S1, S2, S3, S4, S5, Value>

    Parameters

    selector1

    The first Selector

    selector2

    The second Selector

    selector3

    The third Selector

    selector4

    The fourth Selector

    selector5

    The fifth Selector

    projector

    The closure to pass the values from the Selectors to

    Return Value

    A Selector from the given Selectors and the projector function