Publishers.CompactMap
// Publishers.CompactMap Publisher
Publishers.CompactMap(upstream: Publishers.Sequence<[Int?], Never>(sequence: [1, nil, 2])) { $0 }
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine CompactMap Error")
case .finished:
print("Combine CompactMap Finish")
}
}, receiveValue: { value in
print("Combine CompactMap : \(value)")
})
.store(in: &cancellables)
// compactMap Operator
Publishers.Sequence<[Int?], Never>(sequence: [1, nil, 2])
.compactMap { $0 }
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine CompactMap Error")
case .finished:
print("Combine CompactMap Finish")
}
}, receiveValue: { value in
print("Combine CompactMap : \(value)")
})
.store(in: &cancellables)
// Combine CompactMap : 1
// Combine CompactMap : 2
// Combine CompactMap FinishRxSwift
ReactiveSwift
Last updated