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