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.
2 posts - 2 participants