Sign in Go Pro

Android MvRx Fundamentals

Introduction to MvRx


Up next


MvRx is an Android architecture built on top of Android Jetpack that is designed to make practical Android development easier, faster, and more fun. This lesson will walk through the creation of a simple hello world screen and will introduce you to some common pitfalls and challenges that are involved with Android development that MvRx helps with.




Will you please share the GitHub link of this project?

Thank you, Mr. Peal.

Using mvrx what is the recommended approach for use cases such as "autocomplete edittext" where you want to connect your ui text rx stream with the viewmodel's methods (i.e. taking the advantages of rx operations like debounce etc)

I would recommend just having a text watcher that calls a function on your ViewModel that sets a state property to the CharSequence it emitted. What rx operations would you do on it?

Thanks for the reply, I was thinking to do something like that in the "view" in order to take advantage of Rx's debounce operator that I will make less requests when my autocomplete edittext queries the api
.debounce(500, TimeUnit.MILLISECONDS)
.subscribe { viewModel.getAddressByPostCode(it.toString()) }

Obviously I need to do write some disposable cancel logic inside fetchAddressByPostCode method in order to cancel earlier api calls
i.e fetchAddressByPostCode logic has
withState {
if (postCode != it.queryText) {

setState {
copy(queryText = postCode)
disposable?.let {it.dispose()}
disposable = repository.getAddress(postCode)
.execute {
copy(addressResults = it)
I hope that is clear. Any thoughts?

BaseMvRxActivity and MvRxViewModelStoreOwner were deprecated at MvRx v1.3.0.

  • If you were using BaseMvRxActivity you can instead now extend from AppCompatActivity.

  • All usages of mvrxViewModelStore can simply be deleted since state saving now happens completely automatically.


Lessons in Android MvRx Fundamentals