lundi 30 mars 2020

Does SharedViewModel violate Single Responsibility Principle?

I have one activity and 4 fragment, I have SharedViewModel which helps me to pass data from Activity to all other Fragments

                             Activity
                                |
                          SharedViewModel
                                |
         ----------------------------------------------------
         |               |                |                 |
      (Fragment A)   (Fragment B)     (Fragment C)    (Fragment D)

Now here you can see that SharedViewModel has Activity along with all Fragment's data. So, one SharedViewModel contain variables and functions of 5 different class, like variables such as LiveData, other database related functions or some network operation related functions.

1) only one function is used as a common to share data between all classes.

2) Other functions are individual functions of all other class.

so is this violate Single Responsibility Principle? If not then how?

Aucun commentaire:

Enregistrer un commentaire