Home > AI > IOS > Combine >

combineLatest(_:)

Example (Apple Official)

The simplest version to combine many publishers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
let pub1 = PassthroughSubject<Int, Never>()
let pub2 = PassthroughSubject<Int, Never>()
 
let cancellable = pub1
    .combineLatest(pub2)
    .sink { print("Result: \($0).") }
 
 
pub2.send(5)
pub1.send(2)
pub2.send(2)
 
pub1.send(3)
pub1.send(45)
 
pub2.send(22)
pub1.send(15)

Leave a Reply