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
Currently, ViewModels have their own scope, and the parent is the application scope:
There should really be an option to have something in between.
Hilt has an "activity retained" scope in between:
In a nearly-single-activity application, this allows us to use Activity as a sort of proxy for scoping. For instance, to implement a LoggedInScope, we can have different activities for logged-in vs not-logged-in workflows. However, this is coupling the framework to business logic.
The problem with ViewModels, particularly in Compose apps, is that a ViewModel can arguably be called an "entry point" into the Dagger graph. Even though a ViewModel will be constructor-injected, it's provided via the ViewModelProvider.Factory.
The existing design should be updated so that there's an Activity component in between, the same as with Hilt. However, it would be nice to provide an option for a different scope via the TangleScope annotation.
Then in TangleViewModelFactory, we can check for a custom scope and use the corresponding component if necessary. If there is no custom scope defined, then the factory would just fall back to the default.
The text was updated successfully, but these errors were encountered:
Currently, ViewModels have their own scope, and the parent is the application scope:

There should really be an option to have something in between.
Hilt has an "activity retained" scope in between:

In a nearly-single-activity application, this allows us to use
Activity
as a sort of proxy for scoping. For instance, to implement aLoggedInScope
, we can have different activities for logged-in vs not-logged-in workflows. However, this is coupling the framework to business logic.The problem with ViewModels, particularly in Compose apps, is that a ViewModel can arguably be called an "entry point" into the Dagger graph. Even though a ViewModel will be constructor-injected, it's provided via the
ViewModelProvider.Factory
.The existing design should be updated so that there's an Activity component in between, the same as with Hilt. However, it would be nice to provide an option for a different scope via the
TangleScope
annotation.Then in
TangleViewModelFactory
, we can check for a custom scope and use the corresponding component if necessary. If there is no custom scope defined, then the factory would just fall back to the default.The text was updated successfully, but these errors were encountered: