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
0
votes
1 answer

Kodeindb error, cant access my data object in my viewmodel

i have a data class for store in db. @kotlinx.serialization.Serializable data class SavedCalculation( override val id: String, val model1: Model1, val model2: Model2 ):org.kodein.db.model.orm.Metadata { …
commandiron
  • 1,019
  • 1
  • 9
  • 25
0
votes
1 answer

Cannot inject context into cookie manager with Kodein

I have the MVVM app build with KMM. ViewModel contains several use cases. Each use case calls methods of Repository and Repository calls NetworkService to execute the API call. Use cases, Repository and NetworkService are in the shared module. I…
Sergei Mikhailovskii
  • 2,100
  • 2
  • 21
  • 43
0
votes
1 answer

Cannot add latest Kodein version to KMM project

I faced the following problem: I need to add Kodein to the Android part of the KMM project. For this purpose, I added Kodein artefacts to the module's build.gradle file: plugins { id("com.android.application") …
Sergei Mikhailovskii
  • 2,100
  • 2
  • 21
  • 43
0
votes
0 answers

unable to find Kodein-db-0.8.1-beta-samplesources.jar in KMP application

I want to add Kodein to my application but I can't add it, it seems. This is the error I get: Could not find kodein-db-0.8.1-beta-samplessources.jar (org.kodein.db:kodein-db:0.8.1-beta). Searched in the following locations: …
James Black
  • 41,583
  • 10
  • 86
  • 166
0
votes
0 answers

How to prevent ViewModel recreation while using Kodein DI?

I tried to use Kodein DI library and used to to bind my Repo, NetworkService and viewModel like this bind() with singleton { instance().create(MovieNetworkService::class.java) } bind() with provider { …
0
votes
1 answer

Fragment.viewLifecycleOwnerLiveData.observe doesn't call with kodein

i'm making an app and i want to separate my UI logic into multiple UI classes with BaseUi class being lifecycle aware. I'm using Kodein as my DI and i have an issue with fragment.viewLifecycleOwnerLiveData.observe not being called when instance of…
0
votes
1 answer

Kodein Scopes, Bind database service to an activity lifecycle

I've been trying to implement a custom scope in kodein for the past day and I am about to rip my hair off. My application is built on 2 activities, one activity for login, the other when the user is logged in (I'll call it MainActivity). I have…
Chnoou
  • 23
  • 5
0
votes
1 answer

Is Kodien verified at Compile Time?

I am starting a new KMM project and I want to integrate a DI system. I found that there are 2 options: Kodein and Koin. Sadly Koin is not verified at compile time like Dagger and I was wondering if Kodein is verified at compile time ? Looking…
0
votes
1 answer

Kodein factory with interface. IDE suggestion produces incorect code

I have the following code in Kodein module bind() with factory { strategy: OrderStrategyType -> val manager: Manager = when (strategy) { OrderStrategyType.VOLATILITY -> VolatilityManager() else ->…
abi
  • 99
  • 8
0
votes
1 answer

How to access an instance from one Kodein module in a different module?

When using Kodein, if I have 2 modules and module B needs to use an instance from module A, is the best practice to import module A into module B or is there a better way to do it? For example, I have a networkingModule: val networkingModule =…
frostyshadows
  • 65
  • 1
  • 4
0
votes
1 answer

Kodein - retrieve ViewModel fragment parent

I'm working on Android, but I guess the concept would be the same on every platforms. I have a fragment A hosting another fragment B using a NavHostFragment. I can retrieve the ViewModel from fragment A easily : class FragmentA : Fragment(),…
0
votes
1 answer

Kodein returns a new instance instead of singleton

I'm new to Kodein and I've got this simple module : import com.myapp.MyApplication.Companion.INSTANCE import com.facebook.flipper.android.AndroidFlipperClient import com.facebook.flipper.core.FlipperClient import…
0
votes
1 answer

Kodein override binding for AndroidTest

I want to override a Kodein binding by a mock before testing my class. There is my Kodein init: val kodein = Kodein { bind() with provider { MyRepository() } } Then my class to test: class MyClass { private val mMyRepository:…
Darri
  • 3
  • 2
0
votes
1 answer

NullPointerException inside Kodein

I'm trying out Kotlin with Kodein and in my current project I'm getting a NPE inside Kodein and I'm don't know why. I have some data classes and matching repositories which deliver a list of them: data class Cat(val name: String) data class Dog(val…
RoToRa
  • 37,635
  • 12
  • 69
  • 105
0
votes
1 answer

org.kodein.di.Kodein$NotFoundException: 2 bindings found that match bind()

I have an interface WordsDataSource using which I have implemented two concrete classes namely WordsLocalDataSource that deals with local database and another WordsRemoteDataSource that deals with manipulating data online on the server. The problem…
Vaibhav Dhunde
  • 369
  • 1
  • 4
  • 15