Skip to content

Commit b11a32f

Browse files
authored
First pass at some documentation for combineLatest (#94)
* First pass at some documentation for combineLatest * Add additional docs for extension methods and AsyncCombineLatest2Sequence structure
1 parent f560d1c commit b11a32f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Sources/AsyncAlgorithms/AsyncCombineLatest2Sequence.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12+
/// Creates an asynchronous sequence that combines the latest values from two `AsyncSequence` types
13+
/// by emitting a tuple of the values.
1214
public func combineLatest<Base1: AsyncSequence, Base2: AsyncSequence>(_ base1: Base1, _ base2: Base2) -> AsyncCombineLatest2Sequence<Base1, Base2> {
1315
AsyncCombineLatest2Sequence(base1, base2)
1416
}
1517

18+
/// An `AsyncSequence` that combines the latest values produced from two asynchronous sequences into an asynchronous sequence of tuples.
1619
public struct AsyncCombineLatest2Sequence<Base1: AsyncSequence, Base2: AsyncSequence>: Sendable
1720
where
1821
Base1: Sendable, Base2: Sendable,
@@ -30,6 +33,7 @@ public struct AsyncCombineLatest2Sequence<Base1: AsyncSequence, Base2: AsyncSequ
3033
extension AsyncCombineLatest2Sequence: AsyncSequence {
3134
public typealias Element = (Base1.Element, Base2.Element)
3235

36+
/// The iterator for a `AsyncCombineLatest2Sequence` instance.
3337
public struct Iterator: AsyncIteratorProtocol, Sendable {
3438
enum Partial: Sendable {
3539
case first(Result<Base1.Element?, Error>, Base1.AsyncIterator)

Sources/AsyncAlgorithms/AsyncCombineLatest3Sequence.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12+
/// Creates an asynchronous sequence that combines the latest values from three `AsyncSequence` types
13+
/// by emitting a tuple of the values.
1214
public func combineLatest<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequence>(_ base1: Base1, _ base2: Base2, _ base3: Base3) -> AsyncCombineLatest3Sequence<Base1, Base2, Base3> {
1315
AsyncCombineLatest3Sequence(base1, base2, base3)
1416
}
1517

18+
/// An `AsyncSequence` that combines the latest values produced from three asynchronous sequences into an asynchronous sequence of tuples.
1619
public struct AsyncCombineLatest3Sequence<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequence>: Sendable
1720
where
1821
Base1: Sendable, Base2: Sendable, Base3: Sendable,
@@ -32,6 +35,7 @@ public struct AsyncCombineLatest3Sequence<Base1: AsyncSequence, Base2: AsyncSequ
3235
extension AsyncCombineLatest3Sequence: AsyncSequence {
3336
public typealias Element = (Base1.Element, Base2.Element, Base3.Element)
3437

38+
/// The iterator for a `AsyncCombineLatest3Sequence` instance.
3539
public struct Iterator: AsyncIteratorProtocol, Sendable {
3640
var iterator: AsyncCombineLatest2Sequence<AsyncCombineLatest2Sequence<Base1, Base2>, Base3>.Iterator
3741

0 commit comments

Comments
 (0)