Combines elements from three other publishers and delivers groups of elements as tuples.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
Framework
- Combine
Declaration
func zip<P, Q, R>(_ publisher1: P, _ publisher2: Q, _ publisher3: R) -> Publishers.Zip4<Publishers.Share<Upstream>, P, Q, R> where P : Publisher, Q : Publisher, R : Publisher, Self.Failure == P.Failure, P.Failure == Q.Failure, Q.Failure == R.Failure
Parameters
publisher1
A second publisher.
publisher2
A third publisher.
publisher3
A fourth publisher.
Return Value
A publisher that emits groups of elements from the upstream publishers as tuples.
Discussion
The returned publisher waits until all four publishers have emitted an event, then delivers the oldest unconsumed event from each publisher as a tuple to the subscriber. For example, if publisher P1
emits elements a
and b
, and publisher P2
emits elements c
and d
, and publisher P3
emits the elements e
and f
, and publisher P4
emits the event g
, the zip publisher emits the tuple (a, c, e, g)
. It won’t emit a tuple with elements b
, d
, or f
until P4
emits another event. If any upstream publisher finishes successfuly or fails with an error, the zipped publisher does the same.