Skip to content

Commit

Permalink
Update CombineLatest doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Dec 28, 2023
1 parent 071e157 commit 298bb57
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Sources/OpenCombine/Publishers/Publishers.CombineLatest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
extension Publisher {
/// Subscribes to an additional publisher and publishes a tuple upon receiving output from either publisher.
///
/// Use ``Publisher/combineLatest(_:)`` when you want the downstream subscriber to receive a tuple of the most-recent element from multiple publishers when any of them emit a value. To pair elements from multiple publishers, use ``Publisher/zip(_:)`` instead. To receive just the most-recent element from multiple publishers rather than tuples, use ``Publisher/merge(with:)-7qt71``.
/// Use ``Publisher/combineLatest(_:)`` when you want the downstream subscriber to receive a tuple of the most-recent element from multiple publishers when any of them emit a value. To pair elements from multiple publishers, use ``Publisher/zip(_:)`` instead. To receive just the most-recent element from multiple publishers rather than tuples, use ``Publisher/merge(with:)-394v9``.
///
/// > Tip: The combined publisher doesn't produce elements until each of its upstream publishers publishes at least one element.
///
Expand Down Expand Up @@ -93,15 +93,15 @@ extension Publisher {

/// Subscribes to two additional publishers and publishes a tuple upon receiving output from any of the publishers.
///
/// Use ``Publisher/combineLatest(_:_:)-5crqg`` when you want the downstream subscriber to receive a tuple of the most-recent element from multiple publishers when any of them emit a value. To combine elements from multiple publishers, use ``Publisher/zip(_:_:)-8d7k7`` instead. To receive just the most-recent element from multiple publishers rather than tuples, use ``Publisher/merge(with:_:)``.
/// Use ``Publisher/combineLatest(_:_:)-81vgd`` when you want the downstream subscriber to receive a tuple of the most-recent element from multiple publishers when any of them emit a value. To combine elements from multiple publishers, use ``Publisher/zip(_:_:)-2p498`` instead. To receive just the most-recent element from multiple publishers rather than tuples, use ``Publisher/merge(with:_:)``.
///
/// > Tip: The combined publisher doesn't produce elements until each of its upstream publishers publishes at least one element.
///
/// The combined publisher passes through any requests to *all* upstream publishers. However, it still obeys the demand-fulfilling rule of only sending the request amount downstream. If the demand isn’t ``Subscribers/Demand/unlimited``, it drops values from upstream publishers. It implements this by using a buffer size of 1 for each upstream, and holds the most-recent value in each buffer.
///
/// All upstream publishers need to finish for this publisher to finish. If an upstream publisher never publishes a value, this publisher never finishes.
///
/// In this example, three instances of ``PassthroughSubject`` emit values; as ``Publisher/combineLatest(_:_:)-5crqg`` receives input from any of the upstream publishers, it combines the latest value from each publisher into a tuple and publishes it:
/// In this example, three instances of ``PassthroughSubject`` emit values; as ``Publisher/combineLatest(_:_:)-81vgd`` receives input from any of the upstream publishers, it combines the latest value from each publisher into a tuple and publishes it:
///
/// let pub = PassthroughSubject<Int, Never>()
/// let pub2 = PassthroughSubject<Int, Never>()
Expand Down Expand Up @@ -185,15 +185,15 @@ extension Publisher {

/// Subscribes to three additional publishers and publishes a tuple upon receiving output from any of the publishers.
///
/// Use ``Publisher/combineLatest(_:_:_:)-48buc`` when you want the downstream subscriber to receive a tuple of the most-recent element from multiple publishers when any of them emit a value. To combine elements from multiple publishers, use ``Publisher/zip(_:_:_:)-16rcy`` instead. To receive just the most-recent element from multiple publishers rather than tuples, use ``Publisher/merge(with:_:_:)``.
/// Use ``Publisher/combineLatest(_:_:_:)-7mt86`` when you want the downstream subscriber to receive a tuple of the most-recent element from multiple publishers when any of them emit a value. To combine elements from multiple publishers, use ``Publisher/zip(_:_:_:)-67czn`` instead. To receive just the most-recent element from multiple publishers rather than tuples, use ``Publisher/merge(with:_:_:)``.
///
/// > Tip: The combined publisher doesn't produce elements until each of its upstream publishers publishes at least one element.
///
/// The combined publisher passes through any requests to *all* upstream publishers. However, it still obeys the demand-fulfilling rule of only sending the request amount downstream. If the demand isn’t ``Subscribers/Demand/unlimited``, it drops values from upstream publishers. It implements this by using a buffer size of 1 for each upstream, and holds the most-recent value in each buffer.
///
/// All upstream publishers need to finish for this publisher to finish. If an upstream publisher never publishes a value, this publisher never finishes.
///
/// In the example below, ``Publisher/combineLatest(_:_:_:)-48buc`` receives input from any of the publishers, combines the latest value from each publisher into a tuple and publishes it:
/// In the example below, ``Publisher/combineLatest(_:_:_:)-7mt86`` receives input from any of the publishers, combines the latest value from each publisher into a tuple and publishes it:
///
/// let pub = PassthroughSubject<Int, Never>()
/// let pub2 = PassthroughSubject<Int, Never>()
Expand Down
12 changes: 6 additions & 6 deletions Sources/OpenCombine/Publishers/Publishers.Merge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension Publisher {

/// Combines elements from this publisher with those from two other publishers, delivering an interleaved sequence of elements.
///
/// Use ``Publisher/merge(with:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:)-5crqg``.
/// Use ``Publisher/merge(with:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:)-81vgd``.
/// To combine elements from multiple upstream publishers, use ``Publisher/zip(_:_:)-2p498``.
///
/// In this example, as ``Publisher/merge(with:_:)`` receives input from the upstream publishers, it republishes the interleaved elements to the downstream:
Expand Down Expand Up @@ -82,7 +82,7 @@ extension Publisher {

/// Combines elements from this publisher with those from three other publishers, delivering an interleaved sequence of elements.
///
/// Use ``Publisher/merge(with:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-48buc``.
/// Use ``Publisher/merge(with:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-7mt86``.
/// To combine elements from multiple upstream publishers, use ``Publisher/zip(_:_:_:)-67czn``.
///
/// In this example, as ``Publisher/merge(with:_:_:)`` receives input from the upstream publishers, it republishes the interleaved elements to the downstream:
Expand Down Expand Up @@ -121,7 +121,7 @@ extension Publisher {

/// Combines elements from this publisher with those from four other publishers, delivering an interleaved sequence of elements.
///
/// Use ``Publisher/merge(with:_:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-48buc``.
/// Use ``Publisher/merge(with:_:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-7mt86``.
/// To combine elements from multiple upstream publishers, use ``Publisher/zip(_:_:_:)-67czn``.
///
/// In this example, as ``Publisher/merge(with:_:_:_:)`` receives input from the upstream publishers, it republishes the interleaved elements to the downstream:
Expand Down Expand Up @@ -165,7 +165,7 @@ extension Publisher {

/// Combines elements from this publisher with those from five other publishers, delivering an interleaved sequence of elements.
///
/// Use ``Publisher/merge(with:_:_:_:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-48buc``.
/// Use ``Publisher/merge(with:_:_:_:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-7mt86``.
/// To combine elements from multiple upstream publishers, use ``Publisher/zip(_:_:_:)-67czn``.
///
/// In this example, as ``Publisher/merge(with:_:_:_:_:_:)`` receives input from the upstream publishers, it republishes the interleaved elements to the downstream:
Expand Down Expand Up @@ -213,7 +213,7 @@ extension Publisher {

/// Combines elements from this publisher with those from six other publishers, delivering an interleaved sequence of elements.
///
/// Use ``Publisher/merge(with:_:_:_:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-48buc``.
/// Use ``Publisher/merge(with:_:_:_:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-7mt86``.
/// To combine elements from multiple upstream publishers, use ``Publisher/zip(_:_:_:)-67czn``.
///
/// In this example, as ``Publisher/merge(with:_:_:_:_:_:)`` receives input from the upstream publishers; it republishes the interleaved elements to the downstream:
Expand Down Expand Up @@ -266,7 +266,7 @@ extension Publisher {

/// Combines elements from this publisher with those from seven other publishers, delivering an interleaved sequence of elements.
///
/// Use ``Publisher/merge(with:_:_:_:_:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-48buc``.
/// Use ``Publisher/merge(with:_:_:_:_:_:_:)`` when you want to receive a new element whenever any of the upstream publishers emits an element. To receive tuples of the most-recent value from all the upstream publishers whenever any of them emit a value, use ``Publisher/combineLatest(_:_:_:)-7mt86``.
/// To combine elements from multiple upstream publishers, use ``Publisher/zip(_:_:_:)-67czn``.
///
/// In this example, as ``Publisher/merge(with:_:_:_:_:_:_:)`` receives input from the upstream publishers, it republishes the interleaved elements to the downstream:
Expand Down
6 changes: 2 additions & 4 deletions Sources/OpenCombine/RootProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
/// by mapping or filtering elements, while only OpenCombine provides time-based
/// operations like
/// ``Publisher/debounce(for:scheduler:options:)`` and
/// ``Publisher/throttle(for:scheduler:latest:)``.
/// <!--Uncomment the following doc when merge and combineLatest is implemented.-->
/// <!--``Publisher/throttle(for:scheduler:latest:)``, and combining operations like-->
/// <!--``Publisher/merge(with:)-7fk3a`` and ``Publisher/combineLatest(_:_:)-1n30g``.-->
/// ``Publisher/throttle(for:scheduler:latest:)``, and combining operations like
/// ``Publisher/merge(with:)-9qb5x`` and ``Publisher/combineLatest(_:_:)-9ip85``.
/// To bridge the two approaches, the property ``Publisher/values-32o4h`` exposes
/// a publisher's elements as an `AsyncSequence`, allowing you to iterate over
/// them with `for`-`await`-`in` rather than attaching a ``Subscriber``.
Expand Down

0 comments on commit 298bb57

Please sign in to comment.