Skip to content

Instantly share code, notes, and snippets.

@JacquesSmuts
Last active May 21, 2019 20:27
Show Gist options
  • Save JacquesSmuts/9d1c10544e72c4d88e978ca65c5f07ff to your computer and use it in GitHub Desktop.
Save JacquesSmuts/9d1c10544e72c4d88e978ca65c5f07ff to your computer and use it in GitHub Desktop.
suspend fun saveUsernameAndPassword(username: String, password: String) {
val result = suspendAsync(StorageService.getInstance()::saveUsernameAndPassword, username, password)
handleResult(result)
}
suspend fun <Input1, Input2, Output> suspendAsync(function: (Input1, Input2, (Output) -> Unit) -> Unit,
inputOne: Input1, inputTwo: Input2) = suspendCoroutine<Output> { continuation ->
function(inputOne, inputTwo) { output ->
continuation.resume(output)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment