Link
@dynamicMemberLookup
final public class Link<B, E, P> : Executable<E> where E : Error, P : AsyncBlockPerformer
Undocumented
-
Primary chain form. All other forms translate into this form.
Declaration
Swift
@discardableResult public func chain<C>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, _ function: @escaping (B, @escaping (Result<C, E>) -> Void) -> Void) -> Link<C, E, P>
Parameters
function
will be executed as a child link of this
Link
. ReceivesB
(the result of thisLink
and generatesC
.Return Value
The child link which has been added to this
Link
‘s child list. Children are executed in parallel. SeeLink
’s description. -
Primary chain form. All other forms translate into this form.
Declaration
Swift
@discardableResult public func chain<C>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, _ function: @escaping (B, @escaping (Result<C, Never>) -> Void) -> Void) -> Link<C, E, P>
Parameters
function
will be executed as a child link of this
Link
. ReceivesB
(the result of thisLink
and generatesC
.Return Value
The child link which has been added to this
Link
‘s child list. Children are executed in parallel. SeeLink
’s description. -
Primary chain form. All other forms translate into this form.
Declaration
Swift
@discardableResult public func chain<C, OtherE: Error>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, _ function: @escaping (B, @escaping (Result<C, OtherE>) -> Void) -> Void) -> Link<C, Error, P>
Parameters
function
will be executed as a child link of this
Link
. ReceivesB
(the result of thisLink
and generatesC
.Return Value
The child link which has been added to this
Link
‘s child list. Children are executed in parallel. SeeLink
’s description. -
finally
creates a subchain which will be executed whether or not the proceeding chain errors. In the case that no error occurs in the proceeding chain, finally is executed after the final link of the chain, as though it had been directly appended there. In the case that an error, the subchain defined byfinally
will be executed after the error handler has finished.Example:
HoneyBee.start { root in root.errorHandler(funcE) .chain(funcA) .finally { link in link.chain(funcZ) } .chain(funcB) .chain(funcC) }
In the preceding example, if no error occurs then the functions will execute in this order:
funcA
,funcB
,funcC
,funcZ
. The error handler,funcE
will not be executed. IffuncB
produces an error, then execution is as follows:funcA
,funcB
,funcE
,funcZ
. The links after the error, (funcC
), will not be executed.Declaration
Swift
@discardableResult public func finally(file: StaticString = #file, line: UInt = #line, _ defineBlock: (Link<B, E, P>) -> Void) -> Link<B, E, P>
Parameters
defineBlock
context within which to define the finally chain.
Return Value
a
Link
with the same execution context as self, but with a finally chain registered. -
Undocumented
Declaration
Swift
public subscript(block: @escaping (B) -> Void) -> Link<Void, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<R>(block: @escaping (B) -> R) -> Link<R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<R>(dynamicMember keyPath: KeyPath<B, R>) -> Link<R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R>(dynamicMember keyPath: KeyPath<B, TripleArgFunction<X, Y, Z, R, E>>) -> AsyncTripleArgFunction<X, Y, Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R>(dynamicMember keyPath: KeyPath<B, DoubleArgFunction<Y, Z, R, E>>) -> AsyncDoubleArgFunction<Y, Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R>(dynamicMember keyPath: KeyPath<B, SingleArgFunction<Z, R, E>>) -> AsyncSingleArgFunction<Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<R>(dynamicMember keyPath: KeyPath<B, ZeroArgFunction<R, E>>) -> AsyncZeroArgFunction<R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R>(dynamicMember keyPath: KeyPath<B, BoundTripleArgFunction<X, Y, Z, R, E, P>>) -> AsyncTripleArgFunction<X, Y, Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R>(dynamicMember keyPath: KeyPath<B, BoundDoubleArgFunction<Y, Z, R, E, P>>) -> AsyncDoubleArgFunction<Y, Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R>(dynamicMember keyPath: KeyPath<B, BoundSingleArgFunction<Z, R, E, P>>) -> AsyncSingleArgFunction<Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<R>(dynamicMember keyPath: KeyPath<B, BoundZeroArgFunction<R, E, P>>) -> AsyncZeroArgFunction<R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R>(dynamicMember keyPath: KeyPath<B, TripleArgFunction<X, Y, Z, R, Never>>) -> AsyncTripleArgFunction<X, Y, Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R>(dynamicMember keyPath: KeyPath<B, DoubleArgFunction<Y, Z, R, Never>>) -> AsyncDoubleArgFunction<Y, Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R>(dynamicMember keyPath: KeyPath<B, SingleArgFunction<Z, R, Never>>) -> AsyncSingleArgFunction<Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<R>(dynamicMember keyPath: KeyPath<B, ZeroArgFunction<R, Never>>) -> AsyncZeroArgFunction<R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R>(dynamicMember keyPath: KeyPath<B, BoundTripleArgFunction<X, Y, Z, R, Never, P>>) -> AsyncTripleArgFunction<X, Y, Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R>(dynamicMember keyPath: KeyPath<B, BoundDoubleArgFunction<Y, Z, R, Never, P>>) -> AsyncDoubleArgFunction<Y, Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R>(dynamicMember keyPath: KeyPath<B, BoundSingleArgFunction<Z, R, Never, P>>) -> AsyncSingleArgFunction<Z, R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<R>(dynamicMember keyPath: KeyPath<B, BoundZeroArgFunction<R, Never, P>>) -> AsyncZeroArgFunction<R, E, P> { get }
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, TripleArgFunction<X, Y, Z, R, OtherE>>) -> AsyncTripleArgFunction<X, Y, Z, R, Error, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, DoubleArgFunction<Y, Z, R, OtherE>>) -> AsyncDoubleArgFunction<Y, Z, R, Error, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, SingleArgFunction<Z, R, OtherE>>) -> AsyncSingleArgFunction<Z, R, Error, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<R, OtherE>(dynamicMember keyPath: KeyPath<B, ZeroArgFunction<R, OtherE>>) -> AsyncZeroArgFunction<R, Error, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, BoundTripleArgFunction<X, Y, Z, R, OtherE, P>>) -> AsyncTripleArgFunction<X, Y, Z, R, Error, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, BoundDoubleArgFunction<Y, Z, R, OtherE, P>>) -> AsyncDoubleArgFunction<Y, Z, R, Error, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, BoundSingleArgFunction<Z, R, OtherE, P>>) -> AsyncSingleArgFunction<Z, R, Error, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<R, OtherE>(dynamicMember keyPath: KeyPath<B, BoundZeroArgFunction<R, OtherE, P>>) -> AsyncZeroArgFunction<R, Error, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
@discardableResult public func onResult(file: StaticString = #file, line: UInt = #line, _ completion: @escaping (Result<B, E>) -> Void) -> Link<B, E, P>
-
Undocumented
Declaration
Swift
@discardableResult public func onResult(file: StaticString = #file, line: UInt = #line, _ completion: @escaping (Result<B, ErrorContext<E>>) -> Void) -> Link<B, E, P>
-
Undocumented
Declaration
Swift
@discardableResult public func onCompletion(file: StaticString = #file, line: UInt = #line, _ completion: @escaping (ErrorContext<E>?) -> Void) -> Link<B, E, P>
-
Undocumented
Declaration
Swift
@discardableResult public func onCompletion(file: StaticString = #file, line: UInt = #line, _ completion: @escaping (E?) -> Void) -> Link<B, E, P>
-
Undocumented
Declaration
Swift
@discardableResult public func onError(file: StaticString = #file, line: UInt = #line, _ completion: @escaping (ErrorContext<E>) -> Void) -> Link<B, E, P>
-
Undocumented
Declaration
Swift
@discardableResult public func onError(file: StaticString = #file, line: UInt = #line, _ completion: @escaping (E) -> Void) -> Link<B, E, P>
-
Undocumented
Declaration
Swift
public func handleError(file: StaticString = #file, line: UInt = #line, _ completion: @escaping (E) -> Void) -> Link<B, Never, P>
-
Undocumented
Declaration
Swift
public func expect<OtherE>(_ other: OtherE.Type, file: StaticString = #file, line: UInt = #line) -> Link<B, OtherE, P> where E == Never, OtherE : Error
-
Undocumented
Declaration
Swift
public func expect<OtherE>(_ other: OtherE.Type, file: StaticString = #file, line: UInt = #line) -> Link<B, Error, P> where OtherE : Error
-
Undocumented
Declaration
Swift
@discardableResult public func chain<R>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, _ function: @escaping (B) -> R) -> Link<R, E, P>
-
Undocumented
Declaration
Swift
@discardableResult public func chain<R>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, _ function: @escaping (B) throws -> R) -> Link<R, Error, P>
-
insert
inserts a value of any type into the chain data flow.Declaration
Swift
public func insert<C>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, _ c: C) -> Link<C, E, P>
Parameters
c
Any value
Return Value
a
Link
whose child links will receivec
as their function argument. -
drop
ignores “drops” the inbound value and returns aLink
whose value isVoid
Declaration
Swift
public var drop: Link<Void, E, P> { get }
Return Value
a
Link
whose child links will receiveVoid
as their function argument. -
tunnel
defines a subchain with whose value is ultimately discarded. The links within thetunnel
subchain run sequentially before the link which is the return value oftunnel
.tunnel
returns aLink
whose execution resultB
is the result the receiver link. Thus the valueB
“hides” or “goes under ground” while the subchain processes and “pops back up” when it is completed. For example:.insert(8) .tunnel { link in link.chain(intToString) //convert int to string } .chain(multiplyInt)
In the example above
insert
results in anInt
into the chain and that int is passed along tointToString
which transform the value into aString
. After thetunnel
context has finished, the original value8
(anInt
) is passed tomultiplyInt
Declaration
Swift
public func tunnel<R, OtherE, OtherP>(file: StaticString = #file, line: UInt = #line, _ defineBlock: (Link<B, E, P>) -> Link<R, OtherE, OtherP>) -> Link<B, OtherE, P> where OtherE : Error, OtherP : AsyncBlockPerformer
Parameters
defineBlock
a block which creates a subchain to be limited.
Return Value
a
Link
whose execution resultR
is discarded. -
Yields self to a new definition block. Within the block the caller may invoke chaining methods on block multiple times, thus achieving parallel chains. Example:
link.branch { stem in stem.chain(func1) .chain(func2) stem.chain(func3) .chain(func4) }
In the preceding example, when
link
is executed it will start the links containingfunc1
andfunc3
in parallel.func2
will execute whenfunc1
is finished. Likewisefunc4
will execute whenfunc3
is finished.Declaration
Swift
public func branch(_ defineBlock: (Link<B, E, P>) -> Void)
Parameters
defineBlock
the block to which this
Link
yields itself. -
Yields self to a new definition block. Within the block the caller may invoke chaining methods on block multiple times, thus achieving parallel chains. Example:
link.branch { stem in let a = stem.chain(func1) .chain(func2) let b = stem.chain(func3) .chain(func4) return (a + b) // operator for .conjoin } .chain(combine)
In the preceding example, when
link
is executed it will start the links containingfunc1
andfunc3
in parallel.func2
will execute whenfunc1
is finished. Likewisefunc4
will execute whenfunc3
is finished.Declaration
Swift
@discardableResult public func branch<C, OtherE, OtherP>(_ defineBlock: (Link<B, E, P>) -> Link<C, OtherE, OtherP>) -> Link<C, OtherE, OtherP> where OtherE : Error, OtherP : AsyncBlockPerformer
Parameters
defineBlock
the block to which this
Link
yields itself.Return Value
The link which is returned from defineBlock
-
Yields self to a new definition block. Within the block the caller may invoke chaining methods on block multiple times, thus achieving parallel chains. Example:
link.branch { stem in let a = stem.chain(func1) .chain(func2) let b = stem.chain(func3) .chain(func4) return (a + b) // operator for .conjoin } .chain(combine)
In the preceding example, when
link
is executed it will start the links containingfunc1
andfunc3
in parallel.func2
will execute whenfunc1
is finished. Likewisefunc4
will execute whenfunc3
is finished.Declaration
Swift
@discardableResult public func branch<C>(_ defineBlock: (Link<B, E, P>) -> Link<C, E, P>) -> Link<C, E, P>
Parameters
defineBlock
the block to which this
Link
yields itself.Return Value
The link which is returned from defineBlock
-
conjoin
is a compliment tobranch
. Within the context of abranch
it is natural and expected to create parallel execution chains. If the process definition wishes at some point to combine the results of these execution chains, thenconjoin
should be used.conjoin
returns aLink
which waits for both the receiver and the argumentLink
s created results. Those results are combined into a tuple(B,C)
which is passed to the child links of the returnedLink
Declaration
Swift
public func conjoin<C>(_ other: Link<C, E, P>) -> Link<(B, C), E, P>
Parameters
other
the
Link
to join withReturn Value
A
Link
which combines the receiver and the arguments results. -
conjoin
is a compliment tobranch
. Within the context of abranch
it is natural and expected to create parallel execution chains. If the process definition wishes at some point to combine the results of these execution chains, thenconjoin
should be used.conjoin
returns aLink
which waits for both the receiver and the argumentLink
s created results. Those results are combined into a tuple(X, Y, C)
which is passed to the child links of the returnedLink
Declaration
Swift
public func conjoin<X, Y, C>(_ other: Link<C, E, P>) -> Link<(X, Y, C), E, P> where B == (X, Y)
Parameters
other
the
Link
to join withReturn Value
A
Link
which combines the receiver and the arguments results. -
conjoin
is a compliment tobranch
. Within the context of abranch
it is natural and expected to create parallel execution chains. If the process definition wishes at some point to combine the results of these execution chains, thenconjoin
should be used.conjoin
returns aLink
which waits for both the receiver and the argumentLink
s created results. Those results are combined into a tuple(X, Y, Z, C)
which is passed to the child links of the returnedLink
Declaration
Swift
public func conjoin<X, Y, Z, C>(_ other: Link<C, E, P>) -> Link<(X, Y, Z, C), E, P> where B == (X, Y, Z)
Parameters
other
the
Link
to join withReturn Value
A
Link
which combines the receiver and the arguments results. -
Returns a new link with the given AsyncBlockperformer. N.B. this does not change the execution queue for the receiver’s function. Example
HoneyBee.start(on: .main) { root in root.setErrorHandlder(handleError) .chain(funcA) .move(to: DispatchQueue.global()) .chain(funcB) }
In the preceding example,
funcA
will run onDispatchQueue.main
andfuncB
will run onDispatchQueue.global()
Declaration
Swift
public func move<OtherP>(to otherPerformer: OtherP, file: StaticString = #file, line: UInt = #line) -> Link<B, E, OtherP> where OtherP : AsyncBlockPerformer
Parameters
otherPerformer
the new
AsyncBlockPerformer
for child linkReturn Value
the receiver
-
limit
defines a subchain with special runtime protections. The links within thelimit
subchain are guaranteed to have at mostmaxParallel
parallel executions.limit
is particularly useful in the context of a fully parallel process when part of the process must access a limited resource pool such as CPU execution contexts or network resources. This method returns aLink
whose execution resultJ
is the result of the final link of the subchain. This permits the chain to proceed naturally after limit. For example:.limit(5) { link in link.chain(resourceLimitedIntGenerator) } .chain(multiplyInt)
In the example above
resourceLimitedIntGenerator
results in anInt
and that int is passed along tomultipyInt
after thelimit
context has finished.Declaration
Swift
@discardableResult public func limit<J, OtherE, OtherP>(_ maxParallel: Int, _ defineBlock: (Link<B, E, P>) -> Link<J, OtherE, OtherP>) -> Link<J, OtherE, OtherP> where OtherE : Error, OtherP : AsyncBlockPerformer
Parameters
maxParallel
the maximum number of parallel executions permitted for the subchains defined by
defineBlock
defineBlock
a block which creates a subchain to be limited.
Return Value
a
Link
whose execution resultJ
is the result of the final link of the subchain. -
retry
defines a subchain with special runtime properties. The defined subchain will execute a maximum ofmaxTimes + 1
times in an attempt to reach a non-error result. If each of themaxTimes + 1
attempts result in error, the error from the last-attempted pass will be send to the registered error handler. If any of the attempts succeeds, the resultR
will be forwarded to the link which is returned from this function. For example:.retry(2) { link in link.chain(transientlyFailingIntGenerator) } .chain(multiplyInt)
In the example above
transientlyFailingIntGenerator
is a function which can fail in non-fatal ways. When it succeeds, the result is anInt
and that int is passed tomultiplyInt
after theretry
.Declaration
Swift
@discardableResult public func retry<R>(_ maxTimes: Int, _ defineBlock: @escaping (Link<B, E, P>) -> Link<R, E, P>) -> Link<R, E, P>
Parameters
maxTimes
the maximum number of times to reattempt the subchain. Thus the subchain is executed at most
maxTimes + 1
defineBlock
a block which creates a subchain to be retried.
Return Value
a
Link
whose execution resultR
is the result of the final link of the subchain.
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, TripleArgFunction<X, Y, Z, R, OtherE>>) -> AsyncTripleArgFunction<X, Y, Z, R, OtherE, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, DoubleArgFunction<Y, Z, R, OtherE>>) -> AsyncDoubleArgFunction<Y, Z, R, OtherE, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, SingleArgFunction<Z, R, OtherE>>) -> AsyncSingleArgFunction<Z, R, OtherE, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<R, OtherE>(dynamicMember keyPath: KeyPath<B, ZeroArgFunction<R, OtherE>>) -> AsyncZeroArgFunction<R, OtherE, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, BoundTripleArgFunction<X, Y, Z, R, OtherE, P>>) -> AsyncTripleArgFunction<X, Y, Z, R, OtherE, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, BoundDoubleArgFunction<Y, Z, R, OtherE, P>>) -> AsyncDoubleArgFunction<Y, Z, R, OtherE, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R, OtherE>(dynamicMember keyPath: KeyPath<B, BoundSingleArgFunction<Z, R, OtherE, P>>) -> AsyncSingleArgFunction<Z, R, OtherE, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<R, OtherE>(dynamicMember keyPath: KeyPath<B, BoundZeroArgFunction<R, OtherE, P>>) -> AsyncZeroArgFunction<R, OtherE, P> where OtherE : Error { get }
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R>(dynamicMember keyPath: KeyPath<B, TripleArgFunction<X, Y, Z, R, Never>>) -> AsyncTripleArgFunction<X, Y, Z, R, Never, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R>(dynamicMember keyPath: KeyPath<B, DoubleArgFunction<Y, Z, R, Never>>) -> AsyncDoubleArgFunction<Y, Z, R, Never, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R>(dynamicMember keyPath: KeyPath<B, SingleArgFunction<Z, R, Never>>) -> AsyncSingleArgFunction<Z, R, Never, P> { get }
-
Undocumented
Declaration
Swift
public subscript<R>(dynamicMember keyPath: KeyPath<B, ZeroArgFunction<R, Never>>) -> AsyncZeroArgFunction<R, Never, P> { get }
-
Undocumented
Declaration
Swift
public subscript<X, Y, Z, R>(dynamicMember keyPath: KeyPath<B, BoundTripleArgFunction<X, Y, Z, R, Never, P>>) -> AsyncTripleArgFunction<X, Y, Z, R, Never, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Y, Z, R>(dynamicMember keyPath: KeyPath<B, BoundDoubleArgFunction<Y, Z, R, Never, P>>) -> AsyncDoubleArgFunction<Y, Z, R, Never, P> { get }
-
Undocumented
Declaration
Swift
public subscript<Z, R>(dynamicMember keyPath: KeyPath<B, BoundSingleArgFunction<Z, R, Never, P>>) -> AsyncSingleArgFunction<Z, R, Never, P> { get }
-
Undocumented
Declaration
Swift
public subscript<R>(dynamicMember keyPath: KeyPath<B, BoundZeroArgFunction<R, Never, P>>) -> AsyncZeroArgFunction<R, Never, P> { get }
-
Primary chain form. All other forms translate into this form.
Declaration
Swift
@discardableResult public func chain<C, OtherE: Error>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, _ function: @escaping (B, @escaping (Result<C, OtherE>) -> Void) -> Void) -> Link<C, OtherE, P>
Parameters
function
will be executed as a child link of this
Link
. ReceivesB
(the result of thisLink
and generatesC
.Return Value
The child link which has been added to this
Link
‘s child list. Children are executed in parallel. SeeLink
’s description. -
Primary chain form. All other forms translate into this form.
Declaration
Swift
@discardableResult public func chain<C>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, _ function: @escaping (B, @escaping (Result<C, Never>) -> Void) -> Void) -> Link<C, Never, P>
Parameters
function
will be executed as a child link of this
Link
. ReceivesB
(the result of thisLink
and generatesC
.Return Value
The child link which has been added to this
Link
‘s child list. Children are executed in parallel. SeeLink
’s description. -
Undocumented
Declaration
Swift
@discardableResult public func onResult(file: StaticString = #file, line: UInt = #line, _ completion: @escaping (B) -> Void) -> Link<B, E, P>
-
When the inbound type is a
Collection
, you may callmap
to asynchronously map over the elements of B in parallel, transforming them withtransform
subchain.Declaration
Swift
public func map<C>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, limit: Int? = nil, acceptableFailure: FailureRate = .none, _ transform: @escaping (Link<B.Iterator.Element, E, P>) -> Link<C, E, P>) -> Link<[C], E, P>
Parameters
transform
the transformation subchain defining block which converts
B.Iterator.Element
toC
Return Value
a
Link
which will yield an array ofC
s to it’s child links. -
When the inbound type is a
Collection
, you may callfilter
to asynchronously filter the elements of B in parallel, usingfilter
subchainDeclaration
Swift
public func filter(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, limit: Int? = nil, acceptableFailure: FailureRate = .none, _ filter: @escaping (Link<B.Iterator.Element, E, P>) -> Link<Bool, E, P>) -> Link<[B.Iterator.Element], E, P>
Parameters
filter
the filter subchain which produces a Bool
Return Value
a
Link
which will yield to it’s child links an array containing thoseB.Iterator.Element
s whichfilter
approved. -
When the inbound type is a
Collection
, you may calleach
Each accepts a define block which creates a subchain which will be invoked once per element of the sequence. TheLink
which is given as argument to the define block will pass to its child links the element of the collection which is currently being processed.Declaration
Swift
@discardableResult public func each<R>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, limit: Int? = nil, acceptableFailure: FailureRate = .none, _ defineBlock: @escaping (Link<B.Element, E, P>) -> Link<R, E, P>) -> Link<[B.Element], E, P>
Parameters
defineBlock
a block which creates a subchain for each element of the Collection
Return Value
a Link which will pass an Array of the nonfailing elements of
B
to its child links -
When the inbound type is a
Collection
, you may callreduce
Reduce accepts a define block which creates a subchain which will be executed sequentially, once per element of the sequence. The result of each successive execution of the subchain will be forwarded to the next pass of the subchain. The result of the final execution of the subchain will be forwarded to the returned link.Declaration
Swift
public func reduce<T>(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, with t: T, acceptableFailure: FailureRate = .none, _ defineBlock: @escaping (Link<(T, B.Element), E, P>) -> Link<T, E, P>) -> Link<T, E, P>
Return Value
a Link which will pass the result of the reduce to its child links.
-
When the inbound type is a
Collection
, you may callreduce
Reduce accepts a define block which creates a subchain which will be executed in parallel, with up to N/2 other subchains. Each subchain combines twoB.Element
s into oneB.Element
. The result of each combination is again combined until a single value remains. This value is forwarded to the returned link.Declaration
Swift
public func reduce(file: StaticString = #file, line: UInt = #line, functionDescription: String? = nil, _ defineBlock: @escaping (Link<(B.Element, B.Element), E, P>) -> Link<B.Element, E, P>) -> Link<B.Element, E, P>
Parameters
defineBlock
a block which creates a subchain to combined two elements of the Collection
Return Value
a Link which will pass the final combined result of the reduce to its child links.