Created
January 25, 2022 10:22
-
-
Save eunjin3786/2853ebf190ca916e4b320dfe17074d34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let completable = Completable.create { observer in | |
observer(.error(SomeError())) | |
return Disposables.create() | |
} | |
// AS IS | |
completable.subscribe(onCompleted: { | |
print("On Completed") | |
}, onError: { error in | |
print("Got a error:", error) | |
}, onDisposed: { | |
}).disposed(by: disposeBag) | |
// Prints | |
Got a error: SomeError() | |
// TO BE | |
Task { | |
do { | |
let value = try await completable.value | |
print("Got a value:", value) | |
} catch { | |
print("Got a error:", error) | |
} | |
} | |
// Prints | |
Got a error: SomeError() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment