Created
January 25, 2022 10:02
-
-
Save eunjin3786/5878292aa65eda0c3e7d56fe806bcc53 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 single = Single<Int>.error(SomeError()) | |
// AS IS | |
single.subscribe(onSuccess: { value in | |
print("Got a value:", value) | |
}, onFailure: { error in | |
print("Got a error:", error) | |
}, onDisposed: { | |
}).disposed(by: disposeBag) | |
// Prints | |
Got a error: SomeError() | |
// TO BE | |
Task { | |
do { | |
let value = try await single.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