[Combine]throttle bug?

let subject = PassthroughSubject<String, Never>()

let throttled = subject.throttle(for: .seconds(10), scheduler: DispatchQueue.main, latest: false)

throttled.sink(receiveValue: {print($0, Date())})
    .store(in: &subscriptions)

subject.send("a")
subject.send("b")
subject.send("c")

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
    subject.send("d")
}

should only output “a”, but why in playground. “d” also can be output.

Hi, if you revisit Chapter 6: Time manipulation operators, and more specifically the throttle operator sub-section, you will see that “When the subject emits its first value, throttle immediately relays it. Then, it starts throttling the output.”

In your case, the initial value is “a” and the first throttled value is “d”.

1 Like