Created
October 27, 2020 07:07
-
-
Save teyyihan/9942e172e3b401a1d8db4457cac61f8f 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 <T> Task<T>.awaitTask(): T? = suspendCoroutine { continuation -> | |
this.addOnCompleteListener { task -> | |
if (task.isSuccessful) { | |
continuation.resume(task.result) | |
} else { | |
continuation.resumeWithException(task.exception!!) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just what I needed, thank you very much 🚀