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
functionwill be executed as a child link of this
Link. ReceivesB(the result of thisLinkand 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
functionwill be executed as a child link of this
Link. ReceivesB(the result of thisLinkand 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
functionwill be executed as a child link of this
Link. ReceivesB(the result of thisLinkand generatesC.Return Value
The child link which has been added to this
Link‘s child list. Children are executed in parallel. SeeLink’s description. -
finallycreates 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 byfinallywill 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,funcEwill not be executed. IffuncBproduces 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
defineBlockcontext within which to define the finally chain.
Return Value
a
Linkwith 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> -
insertinserts 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
cAny value
Return Value
a
Linkwhose child links will receivecas their function argument. -
dropignores “drops” the inbound value and returns aLinkwhose value isVoidDeclaration
Swift
public var drop: Link<Void, E, P> { get }Return Value
a
Linkwhose child links will receiveVoidas their function argument. -
tunneldefines a subchain with whose value is ultimately discarded. The links within thetunnelsubchain run sequentially before the link which is the return value oftunnel.tunnelreturns aLinkwhose execution resultBis 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
insertresults in anIntinto the chain and that int is passed along tointToStringwhich transform the value into aString. After thetunnelcontext has finished, the original value8(anInt) is passed tomultiplyIntDeclaration
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 : AsyncBlockPerformerParameters
defineBlocka block which creates a subchain to be limited.
Return Value
a
Linkwhose execution resultRis 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
linkis executed it will start the links containingfunc1andfunc3in parallel.func2will execute whenfunc1is finished. Likewisefunc4will execute whenfunc3is finished.Declaration
Swift
public func branch(_ defineBlock: (Link<B, E, P>) -> Void)Parameters
defineBlockthe block to which this
Linkyields 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
linkis executed it will start the links containingfunc1andfunc3in parallel.func2will execute whenfunc1is finished. Likewisefunc4will execute whenfunc3is 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 : AsyncBlockPerformerParameters
defineBlockthe block to which this
Linkyields 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
linkis executed it will start the links containingfunc1andfunc3in parallel.func2will execute whenfunc1is finished. Likewisefunc4will execute whenfunc3is finished.Declaration
Swift
@discardableResult public func branch<C>(_ defineBlock: (Link<B, E, P>) -> Link<C, E, P>) -> Link<C, E, P>Parameters
defineBlockthe block to which this
Linkyields itself.Return Value
The link which is returned from defineBlock
-
conjoinis a compliment tobranch. Within the context of abranchit 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, thenconjoinshould be used.conjoinreturns aLinkwhich waits for both the receiver and the argumentLinks created results. Those results are combined into a tuple(B,C)which is passed to the child links of the returnedLinkDeclaration
Swift
public func conjoin<C>(_ other: Link<C, E, P>) -> Link<(B, C), E, P>Parameters
otherthe
Linkto join withReturn Value
A
Linkwhich combines the receiver and the arguments results. -
conjoinis a compliment tobranch. Within the context of abranchit 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, thenconjoinshould be used.conjoinreturns aLinkwhich waits for both the receiver and the argumentLinks created results. Those results are combined into a tuple(X, Y, C)which is passed to the child links of the returnedLinkDeclaration
Swift
public func conjoin<X, Y, C>(_ other: Link<C, E, P>) -> Link<(X, Y, C), E, P> where B == (X, Y)Parameters
otherthe
Linkto join withReturn Value
A
Linkwhich combines the receiver and the arguments results. -
conjoinis a compliment tobranch. Within the context of abranchit 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, thenconjoinshould be used.conjoinreturns aLinkwhich waits for both the receiver and the argumentLinks created results. Those results are combined into a tuple(X, Y, Z, C)which is passed to the child links of the returnedLinkDeclaration
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
otherthe
Linkto join withReturn Value
A
Linkwhich 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,
funcAwill run onDispatchQueue.mainandfuncBwill run onDispatchQueue.global()Declaration
Swift
public func move<OtherP>(to otherPerformer: OtherP, file: StaticString = #file, line: UInt = #line) -> Link<B, E, OtherP> where OtherP : AsyncBlockPerformerParameters
otherPerformerthe new
AsyncBlockPerformerfor child linkReturn Value
the receiver
-
limitdefines a subchain with special runtime protections. The links within thelimitsubchain are guaranteed to have at mostmaxParallelparallel executions.limitis 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 aLinkwhose execution resultJis 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
resourceLimitedIntGeneratorresults in anIntand that int is passed along tomultipyIntafter thelimitcontext 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 : AsyncBlockPerformerParameters
maxParallelthe maximum number of parallel executions permitted for the subchains defined by
defineBlockdefineBlocka block which creates a subchain to be limited.
Return Value
a
Linkwhose execution resultJis the result of the final link of the subchain. -
retrydefines a subchain with special runtime properties. The defined subchain will execute a maximum ofmaxTimes + 1times in an attempt to reach a non-error result. If each of themaxTimes + 1attempts 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 resultRwill 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
transientlyFailingIntGeneratoris a function which can fail in non-fatal ways. When it succeeds, the result is anIntand that int is passed tomultiplyIntafter 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
maxTimesthe maximum number of times to reattempt the subchain. Thus the subchain is executed at most
maxTimes + 1defineBlocka block which creates a subchain to be retried.
Return Value
a
Linkwhose execution resultRis 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
functionwill be executed as a child link of this
Link. ReceivesB(the result of thisLinkand 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
functionwill be executed as a child link of this
Link. ReceivesB(the result of thisLinkand 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 callmapto asynchronously map over the elements of B in parallel, transforming them withtransformsubchain.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
transformthe transformation subchain defining block which converts
B.Iterator.ElementtoCReturn Value
a
Linkwhich will yield an array ofCs to it’s child links. -
When the inbound type is a
Collection, you may callfilterto asynchronously filter the elements of B in parallel, usingfiltersubchainDeclaration
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
filterthe filter subchain which produces a Bool
Return Value
a
Linkwhich will yield to it’s child links an array containing thoseB.Iterator.Elements whichfilterapproved. -
When the inbound type is a
Collection, you may calleachEach accepts a define block which creates a subchain which will be invoked once per element of the sequence. TheLinkwhich 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
defineBlocka 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
Bto its child links -
When the inbound type is a
Collection, you may callreduceReduce 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 callreduceReduce 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.Elements 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
defineBlocka 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.
Link Class Reference