---
title: "combineLatest(_:)"
framework: combine
role: symbol
role_heading: Instance Method
path: "combine/publisher/combinelatest(_:)"
---

# combineLatest(_:)

Subscribes to an additional publisher and publishes a tuple upon receiving output from either publisher.

## Declaration

```swift
func combineLatest<P>(_ other: P) -> Publishers.CombineLatest<Self, P> where P : Publisher, Self.Failure == P.Failure
```

## Parameters

- `other`: Another publisher to combine with this one.

## Return Value

Return Value A publisher that receives and combines elements from this and another publisher.

## Discussion

Discussion Use 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 zip(_:) instead. To receive just the most-recent element from multiple publishers rather than tuples, use 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 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. In this example, PassthroughSubject pub1 and also pub2 emit values; as combineLatest(_:) receives input from either upstream publisher, it combines the latest value from each publisher into a tuple and publishes it. let pub1 = PassthroughSubject<Int, Never>() let pub2 = PassthroughSubject<Int, Never>()

cancellable = pub1     .combineLatest(pub2)     .sink { print("Result: \($0).") }

pub1.send(1) pub1.send(2) pub2.send(2) pub1.send(3) pub1.send(45) pub2.send(22)

// Prints: //    Result: (2, 2).    // pub1 latest = 2, pub2 latest = 2 //    Result: (3, 2).    // pub1 latest = 3, pub2 latest = 2 //    Result: (45, 2).   // pub1 latest = 45, pub2 latest = 2 //    Result: (45, 22).  // pub1 latest = 45, pub2 latest = 22 When all upstream publishers finish, this publisher finishes. If an upstream publisher never publishes a value, this publisher never finishes.

## See Also

### Collecting and republishing the latest elements from multiple publishers

- [combineLatest(_:_:)](combine/publisher/combinelatest(_:_:)-1n30g.md)
- [combineLatest(_:_:_:)](combine/publisher/combinelatest(_:_:_:)-6ekpz.md)
- [combineLatest(_:_:)](combine/publisher/combinelatest(_:_:)-5crqg.md)
- [combineLatest(_:_:_:_:)](combine/publisher/combinelatest(_:_:_:_:).md)
- [combineLatest(_:_:_:)](combine/publisher/combinelatest(_:_:_:)-48buc.md)
