Last active
March 18, 2020 11:13
-
-
Save manuelvicnt/24627d12f52210a3c6fb4c9697327e03 to your computer and use it in GitHub Desktop.
LoginUser suspend fun (compiler generated code) - part 2
This file contains hidden or 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
| /* Copyright 2019 Google LLC. | |
| SPDX-License-Identifier: Apache-2.0 */ | |
| fun loginUser(userId: String?, password: String?, completion: Continuation<Any?>) { | |
| ... | |
| val continuation = completion as? LoginUserStateMachine ?: LoginUserStateMachine(completion) | |
| when(continuation.label) { | |
| ... | |
| 2 -> { | |
| // Checks for failures | |
| throwOnFailure(continuation.result) | |
| // Gets the result of the previous state | |
| continuation.userDb = continuation.result as UserDb | |
| // Resumes the execution of the function that called this one | |
| continuation.cont.resume(continuation.userDb) | |
| } | |
| else -> throw IllegalStateException(...) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment