Skip to content

Instantly share code, notes, and snippets.

@teyyihan
Created October 27, 2020 07:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teyyihan/9942e172e3b401a1d8db4457cac61f8f to your computer and use it in GitHub Desktop.
Save teyyihan/9942e172e3b401a1d8db4457cac61f8f to your computer and use it in GitHub Desktop.
suspend fun <T> Task<T>.awaitTask(): T? = suspendCoroutine { continuation ->
this.addOnCompleteListener { task ->
if (task.isSuccessful) {
continuation.resume(task.result)
} else {
continuation.resumeWithException(task.exception!!)
}
}
}
@ArnyminerZ
Copy link

Just what I needed, thank you very much 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment