Fail
μ λ€λ¦ ꡬ쑰체 | νΉμ μλ¬μ ν¨κ» μ¦μ μ’ λ£νλ Publisher
λ κ°μ μ΄λμ λΌμ΄μ λ₯Ό μ 곡νλ€.
init(error:)Error νλ‘ν μ½μ μ±ννλ κ°μ
errorμΈμμ λκ²¨μ£Όμ΄ ν΄λΉ μλ¬λ₯Ό λ΄κ³ μ¦μ μ’ λ£νλ Publisherλ₯Ό λ§λ λ€.
init(outputType:failure:)Error νλ‘ν μ½μ μ±ννλ κ°μ
failureμΈμμ λκ²¨μ£Όμ΄ ν΄λΉ μλ¬λ₯Ό λ΄κ³ μ¦μ μ’ λ£νλ Publisherλ₯Ό λ§λ λ€.outputTypeμλ νΉμ Output νμ μ κ°μ§ Subscriberμ Publisherμ ν¨κ» λμν΄μΌ ν λ Output νμ μ λ©ν νμ μ λ겨μ€λ€.
Justκ° νΉμ κ°μ λ΄λ €μ£Όκ³ μ’ λ£νλ€λ©΄, Failμ νΉμ μλ¬μ ν¨κ» μ¦μ μ’ λ£νλ€.
Fail(error: error)
.sink(receiveCompletion: { _ in print("Combine Fail Error") }, receiveValue: { })
.store(in: &cancellables)
// Combine Fail ErrorEmtpyλ κ°μ λ΄μ§ μμΌλ―λ‘ receiveValue ν΄λ‘μ μμλ λμμ νμΈν μ μκ³ , receiveCompletion ν΄λ‘μ μμ μ’
λ£νλ λμμ νμΈν μ μλ€.
RxSwift
error μ€νΌλ μ΄ν°λ₯Ό μ¬μ©νμ¬ κ΅¬νν μ μλ€.
Observable<Void>.error(error)
.subscribe(onError: { _ in print("RxSwift Fail Error") })
.disposed(by: disposeBag)
// RxSwift Fail ErrorReactiveSwift
init(error:) μ΄λμ
λΌμ΄μ λ₯Ό μ¬μ©νμ¬ κ΅¬νν μ μλ€.
Combineκ³Ό κ°μ΄ κ°μ λ΄μ§ μμΌλ―λ‘ startWithValues λ©μλλ₯Ό μ¬μ©νλ©΄ λμμ νμΈν μ μκ³ , startWithFailed λ©μλλ₯Ό μ¬μ©νμ¬ μλ¬λ₯Ό λ΄λ λμμ νμΈν μ μλ€.
μ°Έκ³
Last updated
Was this helpful?