Publishers.Breakpoint
μ λ€λ¦ ꡬ쑰체 | μ 곡λ ν΄λ‘μ κ° λλ²κ±°μμ κ·Έ νλ‘μΈμ€λ₯Ό μ€λ¨νλ κ²μ νμλ‘ ν λ λλ²κ±° μκ·Έλμ μΌμΌν€λ Publisher
μ΄λμ λΌμ΄μ λ λ€ κ°μ μΈμλ₯Ό λ°λλ€.
upstream
: μμμ νλ₯΄λ PublisherreceiveSubscription
: Publisherκ° κ΅¬λ μ μ λ¬λ°μ λ μ€νλλ©°, true κ°μ λ°ννμ¬ λλ²κ±° μκ·Έλμ μΌμΌν¬ μ μλ ν΄λ‘μ receiveOutput
: Publisherκ° μμ Publisherλ‘λΆν° μΆλ ₯μ μ λ¬λ°μ λ μ€νλλ©°, true κ°μ λ°ννμ¬ λλ²κ±° μκ·Έλμ μΌμΌν¬ μ μλ ν΄λ‘μ receiveCompletion
: Publisherκ° μλ£λ₯Ό μ λ¬λ°μ λ μ€νλλ©°, true κ°μ λ°ννμ¬ λλ²κ±° μκ·Έλμ μΌμΌν¬ μ μλ ν΄λ‘μ
handleEvents
μ κ°μ μμ μ λμνλ ν΄λ‘μ κ° trueλ₯Ό λ°ννκ² νλ©΄ ν΄λΉ μ΄λ²€νΈ μμ μμ λλ²κ±° μκ·Έλμ μΌμΌν¬ μ μλ€.
breakpoint
λ° breakpointOnError
μ€νΌλ μ΄ν°μ κ΄λ ¨μ΄ μλ€.
// 1. Publishers.Breakpoint Publisher
Publishers.Breakpoint(upstream: Just(Void()),
receiveSubscription: { _ in true },
receiveOutput: { _ in true },
receiveCompletion: { _ in true })
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Breakpoint Error")
case .finished:
print("Combine Breakpoint Finish")
}
}, receiveValue: {
print("Combine Breakpoint")
})
.store(in: &cancellables)
// 2. breakpoint Operator
Just(Void())
.breakpoint(receiveSubscription: { _ in true },
receiveOutput: { _ in true },
receiveCompletion: { _ in true })
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Breakpoint Error")
case .finished:
print("Combine Breakpoint Finish")
}
}, receiveValue: {
print("Combine Breakpoint")
})
.store(in: &cancellables)
// 3. breakpointOnError Operator
Fail<Void, Error>(error: error)
.breakpointOnError()
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Breakpoint Error")
case .finished:
print("Combine Breakpoint Finish")
}
}, receiveValue: {
print("Combine Breakpoint")
})
.store(in: &cancellables)
1κ³Ό 2μ μ½λλ ꡬλ , κ° λ°ν, μλ£ μ΄λ²€νΈκ° μΌμ΄λ λ λλ²κ±° μκ·Έλμ μΌμΌν¨λ€.
3μ μ½λλ μμ Publisherκ° μλ¬λ₯Ό λ΄λ―λ‘ breakpointOnError
μ μν΄ λλ²κ±° μκ·Έλμ μΌμΌν¨λ€.
RxSwift
ν΄λΉ λμμ ꡬννλ μ€νΌλ μ΄ν°λ₯Ό μ 곡νμ§ μλλ€.
ReactiveSwift
ν΄λΉ λμμ ꡬννλ μ€νΌλ μ΄ν°λ₯Ό μ 곡νμ§ μλλ€.
Last updated
Was this helpful?