Question - help to use in Java android kodein provider and instance
See original GitHub issueHow to represent this in java. I don’t understand the implementation in java with android
`class KodeinContainers {
companion object {
@ExperimentalCoroutinesApi
val diBaseProject = Kodein {
bind<RetrofitConfiguration>() with provider { RetrofitConfiguration() }
bind<MealsByBeersNetworkDatasource>() with provider { MealsByBeersNetworkDatasource(instance()) }
bind<MealsByBeersRepository>() with provider { MealsByBeersRepositoryImpl(instance()) }
bind<GetBeersUseCase>() with provider { GetBeersUseCase(instance()) }
bind<MealsByBeersViewModel>() with provider { MealsByBeersViewModel(instance()) }
}
}
}`
i try but my result is this ` public class Containers {
private final Function0<RetrofitInstance> retrofitInstance;
private final GalleryNetworkDataSource galleryNetworkDataSource;
private final AlbumRepository albumRepository;
private final GetAlbumUseCase getAlbumUseCase;
private final AlbumViewModel albumViewModel;
public Containers(DKodein kodein) {
retrofitInstance = kodein.Provider(TT(RetrofitInstance.class),null);
galleryNetworkDataSource = kodein.Instance(TT(GalleryNetworkDataSource.class),null);
albumRepository = kodein.Instance(TT(AlbumRepositoryImpl.class),null);
getAlbumUseCase = kodein.Instance(TT(GetAlbumUseCase.class),null);
albumViewModel = kodein.Instance(TT(AlbumViewModel.class),null);
}
}
`
is correct?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
help to use in Java android kodein provider and instance #241
Question - help to use in Java android kodein provider and instance # ... Instance(TT(GetAlbumUseCase.class),null); albumViewModel = kodein.
Read more >How to instance many parameters for Factory class with Kodein
Your class ReadViewModelFactory has a ReadActivity constructor parameter, which is not bound in Kodein. There are 2 ways you can solve this:.
Read more >Android ViewModel dependency injection with Kodein
In this article I want to talk about how you can inject your view models with parameters easily with a power of Kodein...
Read more >Dependency injection in Android
Dependency injection (DI) is a technique widely used in programming and well suited to Android development. By following the principles of ...
Read more >Kodein + ViewModels. In the world of Android we can use…
Take a look on HomeFragment class. Inside onCreateView method we can see that instance of the ViewModel is provided by ViewModelProviders.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I’ll try to give you some samples as soon as I can
Also you could read this thread on using kodein with java https://github.com/Kodein-Framework/Kodein-DI/issues/242