https://kotlinlang.org logo
#android
Title
# android
h

Hovhannes

08/11/2021, 11:42 AM
Hello, is it ok to use a ViewModel for different fragments/activities?
😶 6
u

Umar Saidu

08/11/2021, 11:43 AM
Yes, it will make your code look clean, better and easier to read
👍 1
a

Artur Schwarz

08/11/2021, 12:23 PM
There’s “SharedViewModel” that is exactly used for this purpose
👍 1
Although i would not suggest you to use just one single shared ViewModel for all Activities/Fragments of your app, since this is not their intended use.
👍 1
2 Views