Last active
November 30, 2019 06:20
-
-
Save seoft/590aadf0b3ba8001ddf1b4ea44040aca to your computer and use it in GitHub Desktop.
This file contains 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 kr.co.seoft.std_of_android_with_kt_mvvm_aac_mock.ui.third | |
import androidx.lifecycle.MutableLiveData | |
import io.reactivex.Observable | |
import io.reactivex.android.schedulers.AndroidSchedulers | |
import io.reactivex.schedulers.Schedulers | |
import kr.co.seoft.std_of_android_with_kt_mvvm_aac_mock.data.AppDatabase | |
import kr.co.seoft.std_of_android_with_kt_mvvm_aac_mock.data.model.User | |
import kr.co.seoft.std_of_android_with_kt_mvvm_aac_mock.ui.VMHelper | |
import kr.co.seoft.std_of_android_with_kt_mvvm_aac_mock.util.e | |
class ThirdVM(private val db: AppDatabase) : VMHelper() { | |
val TAG = "ThirdVM" | |
val mldSetResult = MutableLiveData<String>() | |
fun insertUser(user: User) { | |
"START ${Thread.currentThread().name}".e() | |
addDisposable( | |
Observable.just("") | |
.subscribeOn(Schedulers.computation()) | |
.map { | |
"map1 ${Thread.currentThread().name}".e() | |
} | |
.observeOn(Schedulers.io()) | |
.map { | |
"map2 ${Thread.currentThread().name}".e() | |
} | |
.doOnNext { | |
"doOnNext1 ${Thread.currentThread().name}".e() | |
} | |
.observeOn(AndroidSchedulers.mainThread()) | |
.doOnNext { | |
"doOnNext2 ${Thread.currentThread().name}".e() | |
} | |
.subscribe({ | |
mldSetResult.value = "done" | |
"done ${Thread.currentThread().name}".e() | |
}, { | |
it.printStackTrace() | |
}) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment