So I thought I would try Room
out on a small side-project.
I followed Florina Muntenescu’s example project:
android-architecture-components
I am paying particular attention to classes: UserActivity.kt, UserViewModel.kt, UserDao.kt
UserViewModel#updateUserName()
returns a Completable and has to be subscribed to returning onComplete
or onError
When I attempt to put my equivalent of viewModel.updateUserName(userName)
into an RxBindings
chain.
If I subscribe to it normally I am passed a Disposable!
into the onNext
with a value of "DISPOSED"
in the final .subscribe
The issue is that this will not emit an Error and thus never know if there is an issue
How could I adapt the code below so that the final .subscribe
would return the correct events?
RxTextView.textChanges(editText)
.debounce(250L, TimeUnit.MILLISECONDS, schedulers.main)
.subscribeOn(schedulers.main)
.observeOn(schedulers.disk)
.map({ name ->
viewModel.updateUserName(name)
.subscribe(
{ Timber.d(“Success”) },
{ error -> Timber.d(error, “something went wrong”)) })
})
.observeOn(schedulers.main)
.subscribe(
{ Timber.d("name changed $it}") },
{ Timber.e(it, "name error") })
Thanks in advance
M.
Turn this
To this