Created
December 25, 2018 21:24
-
-
Save hiranya911/50e65e2cc3ea010a5a4b98321195c8b3 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
import com.google.android.gms.tasks.Task | |
import kotlinx.coroutines.experimental.suspendCancellableCoroutine | |
suspend fun <T> Task<T>.await() = | |
suspendCancellableCoroutine<T> { | |
this.addOnSuccessListener(it::resume) | |
this.addOnFailureListener(it::resumeWithException) | |
this.addOnCanceledListener { it.cancel() } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment