Selector
public class Selector<State, Value> : SelectorProtocol
A type which takes a State
and returns a Value
from it.
Selector
s can be based on other Selector
s making it possible to select a combined Value
.
-
An unique identifier used when overriding the
Selector
on theMockStore
.Declaration
Swift
public let id: UUID
-
Creates a
Selector
from akeyPath
.Declaration
Swift
public convenience init(keyPath: KeyPath<State, Value>)
Parameters
keyPath
The
keyPath
to create theSelector
from -
Creates a
Selector
from aprojector
closure.Declaration
Swift
public init(projector: @escaping (State) -> Value)
Parameters
projector
The
projector
closure to create theSelector
from -
Declaration
Swift
public func map(_ state: State) -> Value
-
Creates a
Selector
from aSelector
and aprojector
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
toReturn Value
A
Selector
from the givenSelector
and theprojector
function -
Creates a
Selector
from aSelector
and aKeyPath
.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 theSelector
keyPath
The
KeyPath
to subscript in the value from theSelector
Return Value
A
Selector
from the givenSelector
and theKeyPath
-
Creates a
Selector
from twoSelector
s and aprojector
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
Selector
s toReturn Value
A
Selector
from the givenSelector
s and theprojector
function -
Creates a
Selector
from threeSelector
s and aprojector
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
toReturn Value
A
Selector
from the givenSelector
s and theprojector
function -
Creates a
Selector
from fourSelector
s and aprojector
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
toReturn Value
A
Selector
from the givenSelector
s and theprojector
function -
Creates a
Selector
from fiveSelector
s and aprojector
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
toReturn Value
A
Selector
from the givenSelector
s and theprojector
function