Publishers.Retry
μ λ€λ¦ ꡬ쑰체 | μ€ν¨ν μμ Publisherμ λνμ¬ κ΅¬λ μ λ€μ μμ±νλ κ²μ μλνλ Publisher
μ΄λμ λΌμ΄μ λ λ κ°μ μΈμλ₯Ό λ°λλ€.
upstream: μμμ νλ₯΄λ Publisherretries: μ΅λ μ¬μλ νμ. nilμ΄ λ€μ΄κ°λ©΄ μμ Publisherκ° μλ¬λ₯Ό λ΄μ§ μμ λκΉμ§ μ¬μλνλ€.
μλ₯Ό λ€μ΄ νΉμ λ€νΈμν¬ μμ²μ΄ μ±κ³΅ν λκΉμ§ λ€μ μμ²νλ € νλ€λ©΄ μ΄ λμμ μ¬μ©ν μ μλ€.
retry μ€νΌλ μ΄ν°μ κ΄λ ¨μ΄ μλ€.
// Publishers.Retry Publisher
Publishers.Retry(upstream: Fail<Void, Error>(error: error), retries: 2)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Retry Error")
case .finished:
print("Combine Retry Finish")
}
}, receiveValue: { value in
print("Combine Retry : \(value)")
})
.store(in: &cancellables)
// retry Operator
Fail<Void, Error>(error: error)
.retry(2)
.sink(receiveCompletion: { completion in
switch completion {
case .failure:
print("Combine Retry Error")
case .finished:
print("Combine Retry Finish")
}
}, receiveValue: { value in
print("Combine Retry : \(value)")
})
.store(in: &cancellables)
// Combine Retry Errorμμ μ½λλ μμ Publisherλ‘ Fail Publisherλ₯Ό λͺ
μνμλ€.
κ·Έλ¬λ―λ‘ μ²« ꡬλ μμ μλ¬κ° λ΄λ €μ€κ² λκ³ , μ΄ν λ λ² μ¬μλνλ€.
λ λ²μ μ¬μλμλ λΆκ΅¬νκ³ μλ¬κ° λ΄λ €μ€λ―λ‘ κ²°κ³Όμ μΌλ‘ μλ¬λ₯Ό λΈλ€.
RxSwift
retry μ€νΌλ μ΄ν°λ₯Ό μ¬μ©νμ¬ κ΅¬νν μ μλ€.
ReactiveSwift
retry μ€νΌλ μ΄ν°λ₯Ό μ¬μ©νμ¬ κ΅¬νν μ μλ€.
μ°Έκ³
Last updated
Was this helpful?