Publishers.Output
// 1 : Publishers.Output Publisher
Publishers
.Output(upstream: Publishers.Sequence<[Int], Never>(sequence: [1, 2, 3]), range: 0 ..< 2)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Output Error")
case .finished:
print("Combine Output Finish")
}
}, receiveValue: { value in
print("Combine Output : \(value)")
})
.store(in: &cancellables)
// Combine Output : 1
// Combine Output : 2
// Combine Output Finish
// 2 : prefix Operator
Publishers.Sequence<[Int], Never>(sequence: [1, 2, 3])
.prefix(2)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Output Error")
case .finished:
print("Combine Output Finish")
}
}, receiveValue: { value in
print("Combine Output : \(value)")
})
.store(in: &cancellables)
// Combine Output : 1
// Combine Output : 2
// Combine Output Finish
// 3 : output Operator
Publishers.Sequence<[Int], Never>(sequence: [1, 2, 3])
.output(at: 1)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Output Error")
case .finished:
print("Combine Output Finish")
}
}, receiveValue: { value in
print("Combine Output : \(value)")
})
.store(in: &cancellables)
// Combine Output : 2
// Combine Output Finish
// 4 : output Operator
Publishers.Sequence<[Int], Never>(sequence: [1, 2, 3])
.output(in: 0 ..< 2)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Output Error")
case .finished:
print("Combine Output Finish")
}
}, receiveValue: { value in
print("Combine Output : \(value)")
})
.store(in: &cancellables)
// Combine Output : 1
// Combine Output : 2
// Combine Output FinishRxSwift
ReactiveSwift
μ°Έκ³
Last updated