Publishers.CollectByTime
// Publishers.CollectByTime Publisher
let subject = PassthroughSubject<Int, Never>()
Publishers.CollectByTime(upstream: subject, strategy: .byTimeOrCount(DispatchQueue.main, 1, 2), options: nil)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine CollectByTime Error")
case .finished:
print("Combine CollectByTime Finish")
}
}, receiveValue: { value in
print("Combine CollectByTime : \(value)")
})
.store(in: &cancellables)
// collect Operator
subject
.collect(.byTimeOrCount(DispatchQueue.main, 1, 2))
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine CollectByTime Error")
case .finished:
print("Combine CollectByTime Finish")
}
}, receiveValue: { value in
print("Combine CollectByTime : \(value)")
})
.store(in: &cancellables)RxSwift
ReactiveSwift
Last updated