tunnel(file:line:_:)

public func tunnel<R>(file: StaticString = #file, line: UInt = #line, _ defineBlock: (SafeLink<B>) -> SafeLink<R>) -> SafeLink<B>

tunnel defines a subchain with whose value is ultimately discarded. The links within the tunnel subchain run sequentially before the link which is the return value of tunnel. tunnel returns a SafeLink whose execution result B is the result the receiver link. Thus the value B 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 an Int into the chain and that int is passed along to intToString which transform the value into a String. After the tunnel context has finished, the original value 8 (an Int) is passed to multiplyInt

  • R

    Declaration

    Swift

    public func tunnel<R>(file: StaticString = #file, line: UInt = #line, _ defineBlock: (SafeLink<B>) -> SafeLink<R>) -> SafeLink<B>