Created
July 20, 2019 18:58
-
-
Save LucianoPAlmeida/8cb6b681548f0239f48e54662fa78104 to your computer and use it in GitHub Desktop.
Kotlin coroutines
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
// 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