Created
January 25, 2022 10:16
-
-
Save eunjin3786/147230a7f86cbe3fbb9fd85b0e56f9d6 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 maybe = Maybe<Int>.create { observer in | |
observer(.error(SomeError())) | |
return Disposables.create() | |
} | |
// AS IS | |
maybe.subscribe(onSuccess: { value in | |
print("Got a value:", value) | |
}, onError: { error in | |
print("Got a error:", error) | |
}, onCompleted: { | |
print("On Completed") | |
}, onDisposed: { | |
}).disposed(by: disposeBag) | |
// Prints | |
// Got a error: SomeError() | |
// TO BE | |
Task { | |
do { | |
let value = try await maybe.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