Created
October 2, 2018 11:33
-
-
Save Gnzlt/4e66c7f6f28db34995d4da2a71ff779d to your computer and use it in GitHub Desktop.
RxJava2 Single extension function to convert Google Play Service Task
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
| package com.example | |
| import com.google.android.gms.tasks.Task | |
| import io.reactivex.Single | |
| fun <TResult> Task<TResult>.toSingle(): Single<TResult> = | |
| Single.create<TResult> { emitter -> | |
| addOnSuccessListener { result -> emitter.onSuccess(result) } | |
| addOnFailureListener { error -> emitter.onError(error) } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment