https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
kodein
  • r

    rocketraman

    12/23/2021, 11:13 PM
    Any plans to support #compose-web (JS platform) via
    org.kodein.di:kodein-di-framework-compose
    ?
    b
    r
    • 3
    • 5
  • s

    sendoav

    01/14/2022, 12:45 PM
    Hi All! I'm using Kodein 7.10 in a Compose project. I have an DummyClass included with bindProvider{ DummyClass()} and retrieved with the method val myobject:DummyClass by rememberInstance() in a Composable method. I have noticed that on each compose recomposition a new object of DummyClass is created. Is it correct? I thought the rememberInstance method should provide the same object for recompositions
    r
    • 2
    • 2
  • t

    Tomas Kormanak

    02/04/2022, 2:22 PM
    Hi, is it possible to have multiple bindings for a single interface. And inject all of them into a class? Something like
    interface Handler {}
    class SomeService(val handlers: List<Handler>) { ... }
    di {
      bind<Handler> { ActualHandler1() }
      bind<Handler> { ActualHandler2() }
    
      bind<SomeService> { SomeService(instance())}
    }
    r
    • 2
    • 2
  • t

    Tomas Kormanak

    02/11/2022, 10:53 AM
    Hi, can I bind the same instance to multiple interfaces?
    interface Feature1 {...}
    interface Feature2 {...}
    
    class Service(): Feature1,Feature2 {...}
    
    di {
        bind<Feature1> { singleton {Service()} }
        bind<Feature2> { ... same singleton as above?? }
    }
    r
    • 2
    • 2
  • g

    georgi

    02/12/2022, 9:52 AM
    Hi there 👋 I recently updated to version
    7.10.0
    and it looks like the API for dependency injection changed and now I'm getting errors on the
    instance
    methods. What is the new way of doing this? (I might have missed it in the docs!)
    r
    • 2
    • 11
  • j

    Joost Klitsie

    03/02/2022, 12:43 PM
    hi all! Is there any snapshot release of kodein 8.0.0 so I can play around with ktor 2.0 beta? 🙂
    r
    • 2
    • 2
  • k

    khairil.ushan

    03/02/2022, 8:32 PM
    Hi Everyone, I have question about kodein-di on native platform such as iOS and macOS. If I do the setup the dependency when app start (which is on main thread), is it possible to retrieve/use those dependencies later from non main thread?
    r
    • 2
    • 3
  • a

    ankushg

    03/03/2022, 1:18 AM
    Hi friends! We’re looking into a db for our KMP codebase and were curious about Kodein-DB How does Kodein-DB differ from just serializing objects as Strings using kotlinx.serialization and storing them in SqlDelight? Is the main benefit supposed to be the ability to more conveniently generate indexes, instead of manually extracting them from the JSON?
    s
    s
    • 3
    • 3
  • r

    rocketraman

    03/03/2022, 5:06 PM
    Is there any way to shorten the boiler-plate required for binding singletons where all the dependencies are coming from Kodein e.g.
    // replace
    bindSingleton { Foo(instance(), instance(), instance(), instance(), instance()) }
    // with something like this
    bindSingleton { ::Foo }
    r
    t
    • 3
    • 19
  • b

    Botond Varsányi

    04/01/2022, 1:39 PM
    Hello everyone! How would you use Kodein for view model injection in an android app using Jetpack Compose? Do you have any recommendations or an example project? Thank you
    b
    • 2
    • 2
  • p

    Panagiotis Panos

    04/13/2022, 1:22 PM
    Hello guys, I have a question for Kodein-DB. Are read/write operations async?
    i
    • 2
    • 2
  • j

    jcechace

    04/13/2022, 5:13 PM
    Any release date for Kodein-DI with support for KTOR 2.0?
    r
    • 2
    • 2
  • j

    Joost Klitsie

    04/27/2022, 1:57 PM
    Hello hello! I noticed that in Compose, the subDI's output isn't remembered. I can work around it, but shouldn't there be a kind of rememberSubDI out of the box? I have an app where the main page can switch between other pages, which are all sub components of the main component. When the main component recomposes, my subDI's are re-initialized and that is not so nice 🙂
    • 1
    • 1
  • s

    salomonbrys

    06/08/2022, 2:50 PM
    Hey everyone, We are announcing the future of our libraries, our focus, and our recent reflections. https://medium.com/kodein-koders/moving-forward-with-the-kodein-open-source-initiative-9fc4f6160c84
    👀 5
    👍 4
    💙 3
    m
    j
    +2
    • 5
    • 5
  • j

    Joost Klitsie

    06/14/2022, 1:42 PM
    Hello! Is there an out of the box way to bind an android viewmodel to an interface? Now you can only provide an actual viewmodel by using
    bindProvider { MyViewModel() }
    and then using
    rememberViewModel()
    (using Compose and android x viewmodel libraries)
    • 1
    • 3
  • s

    SrSouza

    06/21/2022, 6:35 PM
    Hi folks, I'm having a issue with Kodein.
    2 bindings found that match bind<X>
    One of the bindings directly bind
    X
    .
    bind<X> scoped singleto { XImplementation()
    another one uses X a delegate implementation.
    class YViewModel(val x: X) : X by x
    
    bind<YViewModel> scoped singleton { YViewModel(x = instance()) }
    I try to use
    Bind(erased<YViewModel>())
    but did not work, any workaround for this? I don't want YViewModel to be considered X (by considered I mean not being accesible through
    instance<X>() = YViewModel
  • y

    y9san9

    06/22/2022, 10:20 AM
    Good day eveeryone, can we somehow retreive Kodein dependencies from swift?
    r
    • 2
    • 1
  • r

    romainbsl

    06/22/2022, 11:27 AM
    Hi everyone 👋, You probably notice the messages above, the Kodein-Framework organisation no longer exist on Github. Everything will now be available under the Kodein Open Source Initiative organisation, here https://github.com/kosi-libs We have updated a few things already, like the documentation. We also are updating our website kodein.net, but if you notice some dead link please notify us, so we can change it. Also, the Kodein-DB library has been archived, but be assure that we are working on our next iteration, much simpler and more powerful! If you have any other question do not hesitate to post them here.
    ✅ 3
    a
    • 2
    • 1
  • y

    Yannick

    06/28/2022, 4:20 PM
    Did anyone get this error when building with minifyEnabled (Kodein 7.12.0)
    Caused by: java.lang.RuntimeException: Invalid TypeToken; must specify type parameters
            at org.kodein.type.TypeReference.<init>(Unknown Source:40)
            at tb.b.<init>(Unknown Source:0)
            at tb.n.invoke(Unknown Source:19)
            at tb.a0.invoke(SourceFile:1)
    I already added the following to my
    <http://proguard-rules.pro|proguard-rules.pro>
    -keep class org.kodein.type.TypeReference { *; }
    -keep class org.kodein.type.TypeToken { *; }
    Also I can't access the docs regarding proguard https://docs.kodein.org/kodein-di/7.6/framework/android.html#_proguard_configuration Website seems to be down
    r
    • 2
    • 2
  • m

    Matt Nelson

    07/17/2022, 3:14 AM
    Just started using Kodein in my project. Loving this dsl. 👏
    ❤️ 2
    💯 1
  • y

    Yousef

    07/25/2022, 8:57 PM
    I just started using kodein for a desktop compose project, I'm getting a "missing DI container" error. What can be causing this?
    b
    r
    • 3
    • 14
  • h

    Hylke Bron

    08/11/2022, 12:56 PM
    Hi, in my project I am using Kodein DI for the DI framework. It works brilliantly, but today me and my colleague ran into the following issue on ios:
    Uncaught Kotlin exception: kotlin.NullPointerException
        at 0   LibName                             0x102a360e2        kfun:kotlin.Exception#<init>(){} + 50 
        at 1   LibName                             0x102a3616f        kfun:kotlin.RuntimeException#<init>(){} + 31 
        at 2   LibName                             0x102a53a35        ThrowNullPointerException + 165 
        at 3   LibName                             0x102a63771        kfun:kotlin.collections.HashMap#get(1:0){}1:1? + 177 
        at 4   LibName                             0x102be18e0        kfun:org.kodein.di.bindings.StandardScopeRegistry#getOrCreate(kotlin.Any;kotlin.Boolean;kotlin.Function0<org.kodein.di.bindings.Reference<kotlin.Any>>){}kotlin.Any + 304 
        at 5   LibName                             0x102be42ca        kfun:org.kodein.di.bindings.Singleton.$getFactory$lambda-3$FUNCTION_REFERENCE$90.invoke#internal + 650 
        at 6   LibName                             0x102bdcb94        kfun:org.kodein.di.DIContainer.$provider$lambda-0$FUNCTION_REFERENCE$79.invoke#internal + 212 
        at 7   LibName                             0x102bdc10d        kfun:org.kodein.di.$Instance$lambda-0$FUNCTION_REFERENCE$78.invoke#internal + 1949 
        at 8   LibName                             0x102bfb243        kfun:org.kodein.di.DIProperty.$provideDelegate$lambda-0$FUNCTION_REFERENCE$124.invoke#internal + 547 
        at 9   LibName                             0x102a41708        kfun:kotlin.native.concurrent.SynchronizedLazyImpl#<get-value>(){}1:0 + 2024 
        at 10  LibName                             0x102c139da        kfun:my.company.name.<get-dependency>#internal + 186
    The reproduction path is weird, we had to start, stop and start the application before it would crash. I dont have the time to distill a better reproduction path unfortunately, but i suspect it has something to do with race conditions while obtaining a singleton value. In my kotlin code I launch two coroutine jobs, which are executed as soon as the ios app starts:
    coroutineScope {
        launch { /*something that eventually will use the DI container; i.e. private val dependency: Dependency by instance()*/ }
        launch { /*something that eventually will use the DI container; i.e. private val dependency: Dependency by instance()*/ }
    }
    I think this might be a concurrency issue with the native implementation of this library. Maybe its related to the fact that I am using the new experimental memory model. (which works fine by the way). My current solution is that instead of binding instances with
    bindSingleton { instance }
    , I now use
    bindEagerSingleton { instance }
    . The fact that this solves my issue also points in the direction that there are some concurrency issues in the di library. No need for direct assistence, but maybe if someone of the kodein team reads this they might gain some new insight.
  • t

    Tomas Kormanak

    08/17/2022, 8:52 AM
    Hi, I have a problem with
    DependencyLoopException
    We have a loop in dependencies which I think is alright in our case. We use construction injection (no DiAware interface). I was hoping that using a provider can solve it, but it seems not. Any ideas?
    bind<EventBus>
        ╔╩>bind<Set<out EventHandler<in Event>>>
        ║  ╚>bind<NotificationService>
        ║    ╚>bind<EventBus>
        ╚══════╝
    class LocalEventdBus: EventBus (
        handlerProvider: () -> Set<EventHandler<Event>>,
    ) {...}
    bindSingleton<EventBus> { LocalEventBus(provider()) }
    r
    • 2
    • 1
  • f

    František Jeřábek

    08/29/2022, 5:55 PM
    Hi. I am trying to use DI with compose for web. I have
    kodein-di-framework-compose
    library and when I try to attach the di to composable i am getting `content is not a function`error for some reason. The code is just simple composable.
    @Composable
    fun App() = withDI({
    }) {
        Text("Hello world")
    }
    I have these dependencies
    implementation("org.kodein.di:kodein-di:7.12.0")
    implementation("org.kodein.di:kodein-di-framework-compose:7.12.0")
    The error looks like this
    Uncaught TypeError: content is not a function
        at CompositionLocalProvider$composable (CompositionLocal.kt?857d:228:5)
        at withDI$composable (withDI.kt?309d:15:5)
        at App$composable (Main.kt?7792:19:13)
        at eval (Main.kt?7792:26:9)
        at ComposableLambdaImpl.invoke_5qf8pc_k$ (ComposableLambda.js.kt?a45e:116:22)
        at eval (KotlinRegulator.js:1163:25)
        at eval (renderComposable.kt?e3c2:61:9)
        at ComposableLambdaImpl.invoke_6harzl_k$ (ComposableLambda.js.kt?a45e:107:22)
        at eval (web-internal-web-core-runtime.js:446:25)
        at invokeComposable$composable (Composer.js.kt?6ed4:20:16)
    I guess i am using something wrong, but i just cant figure out what it is
    • 1
    • 1
  • a

    Alper Tekin

    09/01/2022, 1:24 PM
    Hi Kodeiners, 👋 (Shared module) I have multi-module backend architecture and created an HttpClient as singleton as below:
    bindSingleton() { HttpClient(CIO) }
    (Auth module) then I set authentication token to the header using the singleton instance
    val client: HttpClient by closestDI().instance()
     client.config {
                defaultRequest {
                    headers.append(HttpHeaders.Authorization, "$schemes $token")
                }
    (User module) Also, I have http clients that talk to each other in microservices. But it looks like I can’t set auth token to the same instance, no token is set in the header for the client below.
    private val client: HttpClient by instance()
    Kodein: 7.11.0 WDYT? Any suggestion?
    r
    • 2
    • 6
  • r

    romainbsl

    11/14/2022, 5:54 PM
    Hello folks. A new version of Kodein has been released. Version 7.16.0 brings: • Compose 1.2.1 (with Kotlin 1.7.20 and full capabilities (JVM / Android | JS | Native iOS) • A brand new API for multi-binding, you can find more about it here http://kosi-libs.org/kodein/7.16/core/multi-binding.html But here is a small example of it:
    val di = DI {
        bindSet<Configuration> { 
            add { provider { FooConfiguration() } } 
            bind { singleton { BarConfiguration() } } 
        }
    }
    The old API is now deprecated and should be removed in a future version. Enjoy Kodein 7.16.0! And, of course, feedback is always welcome.
  • k

    Kazem Moridi

    12/14/2022, 8:13 PM
    There is no enough information about how to use kodein with viewmodels and save state handler with compose in kodein docs, can someone explain about how to use it, I couldn't find any thing about it
    r
    • 2
    • 9
  • a

    Arjan van Wieringen

    12/19/2022, 5:46 PM
    Just a nice message to the team. I introduced Kodein DI into our project and it was an absolute breeze. What a breath of fresh air compared to all the other DI frameworks I have worked in in various languages. I was introduced to the library by Salomon during the KotlinConf Kopenhagen workshop, so thanks for that!
  • a

    AlexSeleznev

    02/07/2023, 3:11 PM
    Hi all! I'm using kodein with DIGlobalAware approach. Few days later I've updated app dependencies from 5 version to 7... And after that i hav problems with getting bindings from androiXModules.. For me it's android system services as SharedPreferences or InputMethodManager. Logs from kodein show me that this binding is in container, but when i try to inject it in my class or retrieve it from DIGlobalAware i get DI@NotFoundException
    r
    s
    • 3
    • 9
  • b

    benkuly

    02/17/2023, 4:48 PM
    Are there plans to fix this issue? https://github.com/kosi-libs/MocKMP/issues/49
Powered by Linen
Title
b

benkuly

02/17/2023, 4:48 PM
Are there plans to fix this issue? https://github.com/kosi-libs/MocKMP/issues/49
View count: 5