Weighing in on the Holy Architecture War — My take on“Architecture Components”
Yonatan V. Levin
37313

Thanks for the wonderful writing on the very new and very cool arch components! Particularly like the part that hook up Room with real world scenario via LiveData!

One comment here. I’d think “part of the UI logic is moved back to View” is a false claim.

Let’s say using data binding, we have a viewHolder that holds a binding to a view. Further let viewModel depend on the viewHolder. Then the LiveData.observe() can be scheduled within the viewModel itself. To that end, all we need to do is to further let viewMode depend on the same LifeCycleOwner that was used to provide the viewModel.

liveData.observe(viewMode.lifeCycleOwner, data -> {videMode.updateWith(data); binding.setViewModel(this)});

This should allow us to unit test the the UI logic.

BTW, what would be the best practice if we make rest call to fetch movies and insert into Room db. The rest call might fail and it looks like we need to rely on out-of-band channel to notify the viewModel. LiveData is just not enough in this case.

Happy to see more of your thoughts!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.