Questions tagged [kodein]

For questions regarding the libraries of the Kodein Framework (a Kotlin/Multiplatform architecture component framework). Questions should specify which library is being asked about (DI, DB, Log, etc.) as well as the source-set in which the problem occurs (Android, Native, Common, etc.).

The Kodein Framework

The Kodein Framework provides several libraries that can be used independently or together. Each provides an opinionated architecture component to ease and accelerate Kotlin/Multiplatform applications.

Links:

Tag usage

When posting questions about Kodein libraries, please make sure to include:

  • The source-set where the issue arises (common, intermediate, platform).
  • The target system & compiler (Android, JVM, JS, Native).
  • Kotlin version.
89 questions
1
vote
1 answer

How to pass parameter for Kodein Injected instances?

In Kodein, when I have the below binding bind() with singleton { AppDependent("abc", instance(), instance()) } I could get my appDependent using below private val appDependent : AppDependent by instance( However if I…
Elye
  • 53,639
  • 54
  • 212
  • 474
1
vote
2 answers

Kotlin Kodein NotFoundException: No binding found for bind() with ?()

I have a very simple set up. But I am unable to perform any networking within my the fragment that I am using Kodein in. The fragment inflates and handles all interaction but the networking layer dependency is somehow missing because I receive:…
Sakiboy
  • 7,252
  • 7
  • 52
  • 69
1
vote
0 answers

Custom AndroidJUnitRunner not being used despite following examples

I am trying to use a custom AndroidJUnitRunner implementation with ActivityScenarios. The goal is to provide the unit tests an Application instance that is KodeinAware. However, despite following the examples found online, the custom runner does not…
1
vote
1 answer

Can I use one Factory to bind viewmodel / repository calls with kodein

In this Factory I need to fetch my data from an api using Retrofit and store the cache with room, my Repository rules this app! I have repository suspended functions that take care of getting my data and some that save/update data getting and…
user6746956
1
vote
1 answer

How to have multiple base URL in retrofit2 using Kotlin and Kodein structure

I have followed THIS tutorial for MVVM and Retrofit2 with Kodein structure/framework. I wanted to know, Using this same framework/structure how can i have multiple base URLs in a single App. Below is the code of "MyApi" interface which have an…
KhanStan99
  • 414
  • 8
  • 20
1
vote
1 answer

I'm struggling to understand Dagger. Can someone me how this Kodein implementation would look in Dagger?

I am required to learn Dagger 2 for a new project and am struggling a bit to make sense of it all. I've looked at some Tutorials which give some clarity but I'm still confused by quite a bit, for example how the various moving pieces (Components,…
Glenncito
  • 902
  • 1
  • 10
  • 23
1
vote
0 answers

How to get rid of callback amount, better design?

For Android: I have a core library with some basic functions: libCore . libCore is written is Java and contains some basic functions with calculations, does not contain any Android related libraries, pure Java. It has an interface offering those…
1
vote
1 answer

Kodein cleanup/destroy method

I'm using kodein (Kodein.global variant) for my LibGDX project. A lot of LibGDX objects have their own cleanup methods (dispose and Disposable interface) which are called after the object is no longer in use and ready for GC cleanup (when switching…
MrPlow
  • 1,295
  • 3
  • 26
  • 45
1
vote
1 answer

Kodein using generics to bind dependencies

I tried to bind the dependencies in the following way fun getKodeinConfigurationsGraph(context: Context, url: String) = Kodein.lazy { import(dataBaseModule(context)) import(retrofitModule(url)) bind() with…
1
vote
1 answer

Is there way to create a factory binding in kotlin kodein, which can produce null?

Is there way to create a factory binding, which can produce null? For example, bind with factory { x: Int -> when (x) { 1 -> "A" 2 -> "B" else -> null } } Unfortunately, bind gives error.
Alexey
  • 2,980
  • 4
  • 30
  • 53
1
vote
1 answer

Passing lambda as argument in Kodein

I am using Kodein for dependency injection on Android (in Kotlin, of course), but I am struggling with one aspect: I can't seem to pass a lambda as an argument to a factory. It compiles correctly but fails at runtime (something I though Kodein as…
Joel Shea
  • 789
  • 7
  • 21
0
votes
1 answer

How to provide SqlDelight database in Compose Multiplatform using KodeIn

So far i've managed to declare expect class for DriverFactory expect class DriverFactory { fun createDriver(): SqlDriver } actual class DriverFactory(private val context: Context) { actual fun createDriver(): SqlDriver { return…
0
votes
0 answers

Android Dynamic Feature Module with kodein frame work

What is the best way to use kodein with Android Dynamic feature module? Dyanamic module will be downloaded latter at some point. Is there any way to dynamically add module to kodein dependency. /* current code */ override val di = DI.lazy { …
Mayupal
  • 1
  • 1
0
votes
1 answer

how to make many ViewModelFactory in kodein with kotlin

i use kodein principle in mvvm to set my ViewModelFactory with repositories class AddSpendApplication: Application(), KodeinAware { override val kodein: Kodein = Kodein.lazy { import(androidXModule(this@AddSpendApplication)) bind() from…
0
votes
0 answers

How to use Kodein in KMM?

I have this initializer of Kodein in commonMain module: @ThreadLocal object CommonInjector { val kodeinContainer = DI.lazy { importAll(mainModule) } val mainModule = DI.Module("main") { bind()…
Denis Sologub
  • 7,277
  • 11
  • 56
  • 123