Subscribes to two additional publishers and invokes a closure upon receiving output from any of the publishers.
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
A second publisher to combine with the first publisher.
A third publisher to combine with the first publisher.
A closure that receives the most-recent value from each publisher and returns a new value to publish.
A publisher that receives and combines elements from this publisher and two other publishers.
combine to combine the current and two additional publishers and transform them using a closure you specify to publish a new value to the downstream.
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
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. If any of the combined publishers terminates with a failure, this publisher also fails.
In the example below,
combine receives the most-recent values published by three publishers, multiplies them together, and republishes the result: