diff --git a/app/src/main/java/keijumt/devandroid/viewmodel/AsyncViewModel.kt b/app/src/main/java/keijumt/devandroid/viewmodel/AsyncViewModel.kt index 6f675f3..6edc5e9 100644 --- a/app/src/main/java/keijumt/devandroid/viewmodel/AsyncViewModel.kt +++ b/app/src/main/java/keijumt/devandroid/viewmodel/AsyncViewModel.kt @@ -2,8 +2,10 @@ import android.os.AsyncTask import io.reactivex.Single +import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.rxkotlin.Singles import io.reactivex.rxkotlin.subscribeBy +import io.reactivex.schedulers.Schedulers import keijumt.devandroid.common.Task import kotlinx.coroutines.experimental.async import kotlinx.coroutines.experimental.launch @@ -34,6 +36,7 @@ fun rx() { val disposable = Singles .zip(rxCalc(3), rxCalc(5)) { num1, num2 -> num1 * num2 } + .observeOn(AndroidSchedulers.mainThread()) .subscribeBy( onSuccess = { println(it) @@ -43,6 +46,7 @@ } fun rxCalc(num: Int) = Single.create { + println(Thread.currentThread().name) it.onSuccess(num * num) - } + }.subscribeOn(Schedulers.computation()) } \ No newline at end of file