You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We already have ScopedRetainedActivity, it can be written as:
val module = module {
scope(named<ScopedRetainedActivity>()) {
scoped {
MyViewModel(get())
}
scoped<Repository> {
RepositoryImpl()
}
}
}
class ScopedRetainedActivity:RetainedScopeActivity(){}
Why is there a ScopeViewModel? Shouldn't a ViewModel not be consistent with the lifecycle of a RetainedActivity or Fragment? Or is it that the ScopeViewModel maintains a smaller lifecycle scope here?Or sometimes, when we ourselves maintain a ViewModel with a longer lifecycle through ViewModelStoreOwner, should we use this ScopeViewModel?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We already have ScopedRetainedActivity, it can be written as:
Why is there a ScopeViewModel? Shouldn't a ViewModel not be consistent with the lifecycle of a RetainedActivity or Fragment? Or is it that the ScopeViewModel maintains a smaller lifecycle scope here?Or sometimes, when we ourselves maintain a ViewModel with a longer lifecycle through ViewModelStoreOwner, should we use this
ScopeViewModel
?Beta Was this translation helpful? Give feedback.
All reactions