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
Hi, I'm migrating from dagger and noticed this library supports assisted injection natively, so I'm triying it out (I didn't use it in dagger because of the extra dependency).
At UI layer I have conductor Controller (Fragment equivalent), which has all the lifecycle callbacks & functions + it implements navigation for me
class ChatViewModel(
private val dispatcherProvider: DispatcherProvider,
private val intentHelper: IntentHelper,
private val navigator: ChatNavigator
)
class ChatController : conductor.Controller, ChatNavigator
interface ChatNavigator {
fun goToFoo()
}
class IntentHelper(private val controller: Controller)
My current solution for this is to have a manual Factory
class ChatViewModelFactory @Inject constructor(
private val dispatcherProvider: DispatcherProvider,
) {
fun create(controller: ChatController) {
return ChatViewModel(
dispatcherProvider = dispatcherProvider,
intentHelper = IntentHelper(controller),
navigator = controller
)
}
}
Is this something I can do away with using @Assisted?
Simple example obviously works
@Inject
class ChatViewModel(
private val dispatcherProvider: DispatcherProvider,
@Assisted private val navigator: ChatNavigator
)
But adding the IntentHelper causes me trouble
@Inject
class ChatViewModel(
private val dispatcherProvider: DispatcherProvider,
private val intentHelper: IntentHelper, <------------
@Assisted private val navigator: ChatNavigator
)
@Inject
class IntentHelper(@Assisted private val controller: Controller) <------
I'm trying to have it be part of the graph & have the controller asgument be assisted, but that then obviously requires the view model to depend on the factory private val intentHelper: (Controller) -> IntentHelper,, not the type itself
So .. is this even possible, or am I stuck with manual factories? (to not have Controller dependency explicitly in viewmodel constructor signature)
The text was updated successfully, but these errors were encountered:
Hi, I'm migrating from dagger and noticed this library supports assisted injection natively, so I'm triying it out (I didn't use it in dagger because of the extra dependency).
At UI layer I have conductor Controller (Fragment equivalent), which has all the lifecycle callbacks & functions + it implements navigation for me
My current solution for this is to have a manual Factory
Is this something I can do away with using
@Assisted
?Simple example obviously works
But adding the
IntentHelper
causes me troubleI'm trying to have it be part of the graph & have the
controller
asgument be assisted, but that then obviously requires the view model to depend on the factoryprivate val intentHelper: (Controller) -> IntentHelper,
, not the type itselfSo .. is this even possible, or am I stuck with manual factories? (to not have Controller dependency explicitly in viewmodel constructor signature)
The text was updated successfully, but these errors were encountered: