Skip to content

Instantly share code, notes, and snippets.

@LucianoPAlmeida
Created July 20, 2019 18:58
Show Gist options
  • Save LucianoPAlmeida/8cb6b681548f0239f48e54662fa78104 to your computer and use it in GitHub Desktop.
Save LucianoPAlmeida/8cb6b681548f0239f48e54662fa78104 to your computer and use it in GitHub Desktop.
Kotlin coroutines
// func getUser(userid: String, continuation: Continuation)
suspend fun getUser(usid: String) {
val sm = CoroutineImpl {}
when (sm.label) {
0 -> {
apiToken(sm)
sm.label = 1
}
1 -> {
findUser(usid, sm.token, sm)
sm.label = 2
}
2 -> {
// Do what you want with the user
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment