Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Last active March 18, 2020 11:13
Show Gist options
  • Select an option

  • Save manuelvicnt/24627d12f52210a3c6fb4c9697327e03 to your computer and use it in GitHub Desktop.

Select an option

Save manuelvicnt/24627d12f52210a3c6fb4c9697327e03 to your computer and use it in GitHub Desktop.
LoginUser suspend fun (compiler generated code) - part 2
/* 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