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