Example (Apple Official):
var WAIT_TIME : Int = 2
var TIMEOUT_TIME : Int = 5
let pub = PassthroughSubject<String, Never>()
let cancellable = pub
.timeout(.seconds(TIMEOUT_TIME), scheduler: DispatchQueue.main, options: nil, customError:nil)
.sink(
receiveCompletion: { print ("completion: \($0) at \(Date())") },
receiveValue: { print ("value: \($0) at \(Date())") }
)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(WAIT_TIME),
execute: {
pub.send("Some data - sent after a delay of \(WAIT_TIME) seconds")
})