I have three fragments A, B and C. B and C are child fragments of A. How do I get all three to share the same view model. From this medium article, this is what I should do:
viewModel = activity?.run {
ViewModelProviders.of(this)[SharedViewModel::class.java]
} ?: throw Exception("Invalid Activity")
}
However this one is about sharing a view model among two fragments and an activity so it can not work right in my case.