CombineLatest3AsyncSequence
public struct CombineLatest3AsyncSequence<P, Q, R> : AsyncSequence where P : AsyncSequence, Q : AsyncSequence, R : AsyncSequence
extension CombineLatest3AsyncSequence: AsyncIteratorProtocol
An asynchronous sequence that combines three async sequences.
The combined sequence emits a tuple of the most-recent elements from each sequence when any of them emit a value.
If one sequence never emits a value this sequence will finish.
let streamA = .init { continuation in
continuation.yield(1)
continuation.yield(2)
continuation.yield(3)
continuation.yield(4)
continuation.finish()
}
let streamB = .init { continuation in
continuation.yield(5)
continuation.yield(6)
continuation.yield(7)
continuation.yield(8)
continuation.yield(9)
continuation.finish()
}
let streamC = .init { continuation in
continuation.yield(10)
continuation.yield(11)
continuation.finish()
}
for await value in streamA.combineLatest(streamB, streamC) {
print(value)
}
// Prints:
// (1, 5, 10)
// (2, 6, 11)
// (3, 7, 11)
// (4, 8, 11)
// (4, 9, 11)
-
The kind of elements streamed.
Declaration
Swift
public typealias Element = (P.Element, Q.Element, R.Element)
-
Creates an async sequence that only emits elements that don’t match the previous element, as evaluated by a provided closure.
Declaration
Swift
public init( _ p: P, _ q: Q, _ r: R )
Parameters
p
An async sequence.
q
An async sequence.
r
An async sequence.
-
next()
AsynchronousProduces the next element in the sequence.
Continues to call
next()
on it’s base iterator and iterator of it’s combined sequence.If both iterator’s return
nil
, indicating the end of the sequence, this iterator returnsnil
.Declaration
Swift
public mutating func next() async rethrows -> Element?
Return Value
The next element or
nil
if the end of the sequence is reached. -
Creates an async iterator that emits elements of this async sequence.
Declaration
Swift
public func makeAsyncIterator() -> CombineLatest3AsyncSequence<P, Q, R>
Return Value
An instance that conforms to
AsyncIteratorProtocol
.