question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question - help to use in Java android kodein provider and instance

See original GitHub issue

How 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
romainbslcommented, Sep 30, 2019

Ok, I’ll try to give you some samples as soon as I can

0reactions
romainbslcommented, Oct 11, 2019

Also you could read this thread on using kodein with java https://github.com/Kodein-Framework/Kodein-DI/issues/242

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found