ViewModel key is calculated against Key and/or Qualifier
ViewModel is only created against root Scope to avoid any leaking (leaking Activity or Fragment ...). This fix the visibility problem, where ViewModel could have access to incompatible scopes.
ScopeViewModel to help work on ViewModel scope like follow:
module {
viewModelOf(::MyScopeViewModel)
scope<MyScopeViewModel> {
scopedOf(::Session)
}
}
class MyScopeViewModel : ScopeViewModel() {
// on onCleared, scope is closed
// injected from current MyScopeViewModel's scope
val session by scope.inject<Session>()
}
ScopeViewModel
to help work on ViewModel scope like follow:Fix #1750