Is there versions of bellow Fragment extension fun...
# android-architecture
p
Is there versions of bellow Fragment extension functions that receive a
key
String parameter.
Copy code
Fragment.activityViewModels(...) -> Fragment.activityViewModels(key: Any, ...) 
Fragment.navGraphViewModels(...) -> Fragment.navGraphViewModels(key: Any, ...)
They both getOrCreate a new ViewModel instance based on the
class
. I have 2 or more instances of the same Fragment Type in the same Activity or NavGraph. They need to have a different ViewModel instance. Using the same
class
type to retrieveOrCreate a ViewModel will return the previous in path Fragment's ViewModel. It could be avoided if each Fragment instance has a unique identifier and above methods had
key: Any
overloads. You might suggest another approach to my use case.