Last active
May 21, 2019 20:28
-
-
Save JacquesSmuts/8ae63a3da81d38708c0c35a300280a86 to your computer and use it in GitHub Desktop.
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
suspend fun saveUsername(username: String) { | |
val result = suspendAsync(StorageService.getInstance()::saveUsername, username) | |
handleResult(result) | |
} | |
suspend fun <Input, Output> suspendAsync(function: (Input, (Output) -> Unit) -> Unit, | |
input: Input) = suspendCoroutine<Output> { continuation -> | |
function(input) { output -> | |
continuation.resume(output) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment