Publishers.PrefixUntilOutput
let sourceSubject = PassthroughSubject<Int, Never>()
let otherSubject = PassthroughSubject<Int, Never>()
// Publishers.PrefixUntilOutput Publisher
Publishers
.PrefixUntilOutput(upstream: sourceSubject, other: otherSubject)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine PrefixUntilOutput Error")
case .finished:
print("Combine PrefixUntilOutput Finish")
}
}, receiveValue: { value in
print("Combine PrefixUntilOutput : \(value)")
})
.store(in: &cancellables)
// prefix Operator
sourceSubject
.prefix(untilOutputFrom: otherSubject)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine PrefixUntilOutput Error")
case .finished:
print("Combine PrefixUntilOutput Finish")
}
}, receiveValue: { value in
print("Combine PrefixUntilOutput : \(value)")
})
.store(in: &cancellables)
// 1
sourceSubject.send(1)
// 2
otherSubject.send(2)
// 3
sourceSubject.send(3)
// Combine PrefixUntilOutput : 1
// Combine PrefixUntilOutput FinishRxSwift
ReactiveSwift
μ°Έκ³
Last updated