Optional.Publisher
ꡬ쑰체 | μ΅μ λμ΄ κ°μ κ°μ§κ³ μμΌλ©΄, κ° Subscriberμκ² μ νν ν λ² μ΅μ λ κ°μ λ°ννλ Combine Publisher
μ΄λμ λΌμ΄μ λ ν κ°μ μΈμλ₯Ό λ°λλ€.
output
: κ° Subscriberμκ² μ λ¬ν μ΅μ λ κ°μ΅μ λ κ°μ΄ nilμ΄ μλλΌλ©΄ μ΅μ λμ΄ λ²κ²¨μ§ κ°μ μ λ¬νκ³ μ’ λ£νλ€.
μ΅μ λ κ°μ΄ nilμ΄λΌλ©΄ κ°μ μ λ¬νμ§ μκ³ λμ μ μμ μΌλ‘ μ’ λ£νλ€.
// 1
Optional.Publisher(Void())
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Optional Error")
case .finished:
print("Combine Optional Finish")
}
}, receiveValue: {
print("Combine Optional")
})
.store(in: &cancellables)
// Combine Optional
// Combine Optional Finish
// 2
Optional.Publisher(nil)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Optional Error")
case .finished:
print("Combine Optional Finish")
}
}, receiveValue: {
print("Combine Optional")
})
.store(in: &cancellables)
// Combine Optional Finish
1μ μ½λλ μΈμλ‘ nilμ΄ μλ λ€μ΄κ°μΌλ―λ‘ μ΅μ λμ λ²κΈ΄ κ°μ λ΄κ³ μ’ λ£νλ€.
2μ μ½λλ μΈμλ‘ nilμ΄ λ€μ΄κ°μΌλ―λ‘ κ·Έλλ‘ μ’ λ£νλ€.
Last updated
Was this helpful?