Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
Created February 9, 2021 07:06
Show Gist options
  • Save EmmanuelGuther/04b5f1da8f2e34010da44edd17d6f451 to your computer and use it in GitHub Desktop.
Save EmmanuelGuther/04b5f1da8f2e34010da44edd17d6f451 to your computer and use it in GitHub Desktop.
private suspend fun getToken(foo: String): String? = suspendCoroutine { continuation ->
val fooToken = tokenApiExample.Token(foo).start
fooToken.onCreateTokenListener { data ->
when {
data.has("id") -> {
val token = data.getString("id")
continuation.resume(token)
}
else -> {
continuation.resume(null)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment