Publishers.MapKeyPath
μ λ€λ¦ ꡬ쑰체 | ν€ κ²½λ‘μ κ°μ λ°ννλ Publisher
μ΄λμ λΌμ΄μ λ₯Ό μ 곡νμ§ μλλ€.
νμ μ ν€ κ²½λ‘λ₯Ό ν΅ν΄ μ κ·Όν κ°μΌλ‘ λ§€ννκΈ° μν΄ μ¬μ©ν μ μλ€.
map
μ€νΌλ μ΄ν°μ κ΄λ ¨μ΄ μλ€.
struct SomeStruct {
let property = "value"
}
Just(SomeStruct())
.map(\.property)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine MapKeyPath Error")
case .finished:
print("Combine MapKeyPath Finish")
}
}, receiveValue: { value in
print("Combine MapKeyPath : \(value)")
})
.store(in: &cancellables)
// Combine MapKeyPath : value
// Combine MapKeyPath Finish
SomeStruct
ꡬ쑰체μ μΈμ€ν΄μ€λ₯Ό λ°ννλ μμ Publisherλ‘λΆν° property
ν€ κ²½λ‘λ₯Ό ν΅ν΄ ν΄λΉ κ°μ μ κ·Όνκ³ κ·Έ κ°μΌλ‘ λ§€ννλ€.
RxSwift
ν΄λΉ λμμ ꡬννκΈ° μν μ€νΌλ μ΄ν°λ₯Ό μ 곡νμ§ μλλ€.
ReactiveSwift
ν΄λΉ λμμ ꡬννκΈ° μν μ€νΌλ μ΄ν°λ₯Ό μ 곡νμ§ μλλ€.
Last updated
Was this helpful?