Publishers.Count
μ λ€λ¦ ꡬ쑰체 | μμμ νλ₯΄λ Publisherλ‘λΆν° μ λ¬λ°μ μμλ€μ κ°μλ₯Ό λ°ννλ Publisher
μ΄λμ λΌμ΄μ λ ν κ°μ μΈμλ₯Ό λ°λλ€.
upstream
: μμμ νλ₯΄λ Publisher
μμ Publisherκ° λ°ννλ μμμ κ°μλ₯Ό λ°°μΆνλ€.
count
μ€νΌλ μ΄ν°μ κ΄λ ¨μ΄ μλ€.
// Publishers.Count Publisher
Publishers
.Count(upstream: Publishers.Sequence<[Int], Never>(sequence: [1, 2, 3]))
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Count Error")
case .finished:
print("Combine Count Finish")
}
}, receiveValue: { value in
print("Combine Count : \(value)")
})
.store(in: &cancellables)
// count Operator
Publishers.Sequence<[Int], Never>(sequence: [1, 2, 3])
.count()
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Count Error")
case .finished:
print("Combine Count Finish")
}
}, receiveValue: { value in
print("Combine Count : \(value)")
})
.store(in: &cancellables)
// Combine Count : 3
// Combine Count Finish
μμ Publisherμ νλ₯΄λ κ°μ κ°μκ° 3μ΄λ―λ‘ μ΅μ’ μ μΌλ‘ 3μ κ°μ λ΄κ³ μ’ λ£νλ€.
RxSwift
ν΄λΉ λμμ ꡬννκΈ° μν μ€νΌλ μ΄ν°λ₯Ό μ 곡νμ§ μλλ€.
ReactiveSwift
ν΄λΉ λμμ ꡬννκΈ° μν μ€νΌλ μ΄ν°λ₯Ό μ 곡νμ§ μλλ€.
μ°Έκ³
Last updated
Was this helpful?