Slackbot
10/26/2019, 4:07 AMTash
10/26/2019, 6:37 AMViewModel
belongs to the Activity
? Just one ViewModel
could be fine especially if things are simple enough and the data flow is unidirectional going towards the independent `Fragment`s. For one of my projects, I define some data models to represent each of the different `Fragment`s I have, and then configure the Activity
level ViewModel
to provide separate `LiveData`s of each of those models. Each Fragment
then observes only the LiveData
that pertains to its own data model.Michael Pohl
10/26/2019, 3:48 PMFreedom
10/27/2019, 8:27 PMAmirul Zin
10/29/2019, 2:08 AMSomesh
10/30/2019, 4:49 AMSomesh
10/30/2019, 4:59 AMViewModel
with the activity sounded little off initially so I tied them to fragment scope and yeah everything is same except the title of the tabs.. and if I tie them to activity then I might not be able to easily load/call the APIs separately with different request as @Amirul Zin stated.