As smartphones get more and more powerful and with bigger screens, the complexity of tasks that people want to be able to do with them follow the same growth. Google has become very opinionated about how to do architecture and best practices, but examples are often overly simplified and not very dynamic.
Fragments are making a comeback, combined with LiveData and ViewModels. As we adopt these architecture components into our apps, how can we build support for complex use cases with multiple fragments on screen? Should each fragment have a ViewModel? What about custom views?
ViewModel Contracts propose the idea of having fragments (and potentially custom views) declare a ViewModel & LiveData via interface to abstract out all of the communication details between nested fragments and their parents. In this talk, we explain in detail how to implement them, how architecture components deal with ViewModels, ViewModelFactories and how we can reuse them.