I'm using the timeout operator in Combine, and my understanding was that it would timeout only if a publisher does not publish an event, but it seems to timeout even if a value is published.
From the docs
A publisher that terminates if the specified interval elapses with no events received from the upstream publisher.
import PlaygroundSupport
import Combine
import Foundation
PlaygroundPage.current.needsIndefiniteExecution = true
let subject = PassthroughSubject<String, Never>()
let cancellable = subject
.timeout(.seconds(5), scheduler: DispatchQueue.main)
.sink(
receiveCompletion: { print ("completion: \($0) at \(Date())") },
receiveValue: { print ("value: \($0) at \(Date())") }
)
subject.send("Sending data")
/*
Prints
value: Sending data at 2021-01-06 22:41:12 +0000
completion: finished at 2021-01-06 22:41:17 +0000
*/
Is my understanding wrong with the operator?.