Created
January 25, 2022 10:08
-
-
Save eunjin3786/c3bc7444ddc2507cf1ef387e6094389e 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(.completed) | |
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 | |
// On Completed | |
// TO BE | |
Task { | |
do { | |
let value = try await maybe.value | |
print("Got a value:", value) | |
} catch { | |
print("Got a error:", error) | |
} | |
} | |
// Prints | |
// Got a value: nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment