https://kotlinlang.org logo
Docs
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
koin
  • a

    arnaud.giuliani

    08/20/2018, 9:12 AM
    you can, check also branch 1.0.0
    a
    1 reply · 2 participants
  • b

    bj0

    08/27/2018, 10:18 PM
    is there a way to inject a (factory) function?
    a
    3 replies · 2 participants
  • b

    Benoit Duffez

    08/30/2018, 7:15 PM
    another typo:
    // Facvtory instance of Presenter
    t
    6 replies · 2 participants
  • c

    chrisjenx

    09/02/2018, 3:59 PM
    @longzma13 as @arnaud.giuliani mentioned above, they are reworking the Scope/Module parts. I would bump back to beta 8 until the docs are updated. As it's changed a little bit.
    l
    1 reply · 2 participants
  • a

    arnaud.giuliani

    09/03/2018, 12:58 PM
    https://github.com/InsertKoinIO/koin/issues/218
    👍 1
    🎉 2
    t
    4 replies · 2 participants
  • h

    Hiosdra

    09/05/2018, 6:30 AM
    Hey, is there any way to resolve one component as default component and second component as named component? Default - without providing anything, and custom - providing it's name like other components? Simple declaring one component wothout name and one with, doesn't work for me. These two components share the same interface. Thanks for help
    t
    a
    5 replies · 3 participants
  • a

    AntoineJojo

    09/11/2018, 1:28 PM
    Hey! Has someone already use
    inject()
    with a generic type? For instance:
    class BaseActivity<P: BasePresenter> { val presenter: P by inject() }
    b
    3 replies · 2 participants
  • t

    tapchicoma

    09/13/2018, 12:23 PM
    you should pass
    loadProperties = true
    to
    startKoin()
    u
    1 reply · 2 participants
  • p

    Paul Woitaschek

    09/15/2018, 4:36 PM
    Is there a project where I can see how coin works in a multi module project?
    s
    3 replies · 2 participants
  • p

    Paul Woitaschek

    09/16/2018, 5:08 AM
    And how do you test that you DI setup is correct and does not throw exceptions at runtime?
    t
    s
    +1
    6 replies · 4 participants
  • p

    pavlospt

    09/19/2018, 6:30 AM
    Why do you need Activity context?
    l
    3 replies · 2 participants
  • p

    pavlospt

    09/19/2018, 6:32 AM
    that would be something that your presenter should delegate to the View
    l
    1 reply · 2 participants
  • e

    esdudnik

    09/20/2018, 3:33 PM
    Hello guys. I have a small project using koin. I stared to write unit test for some classes and face a strange issue. From the beginning everything was fine, but after I added next code in build.gradle file(took this from Robolectric official site)
    testOptions {
            unitTests {
                includeAndroidResources = true
            }
        }
    all of my tests crashed with strange errors. From the beginning I received
    org.koin.error.AlreadyStartedException: Koin is already started. Run startKoin only once or use loadKoinModules
    and when I added
    testImplementation 'org.koin:koin-test:1.0.0'
    I received error
    java.lang.NoSuchMethodError: org.koin.standalone.StandAloneContext.startKoin$default(Lorg/koin/standalone/StandAloneContext;Ljava/util/List;ZLjava/util/Map;ILjava/lang/Object;)Lorg/koin/Koin;
    I extend my test classes from AutoCloseKoinTest() but errors stay the same. Do anybody faced this problem? Or probably somebody know how to fix it. I will appreciate any help.
    t
    5 replies · 2 participants
  • o

    orafaaraujo

    09/24/2018, 7:42 PM
    Hi, everyone How do I inject something inside a
    BroadcastReceiver
    ?
    a
    5 replies · 2 participants
  • h

    hmole

    09/25/2018, 11:19 AM
    Hello. Does Koin works with multiplatform(specifically new
    kotlin-multiplatform
    plugin)
    r
    t
    4 replies · 3 participants
  • r

    ritesh

    09/26/2018, 11:32 AM
    Was wondering what the difference between startKoin() and loadKoinModules() when initializing koin.
    t
    1 reply · 2 participants
  • r

    ritesh

    09/26/2018, 1:53 PM
    Is it possible to create Scope for ViewModels in koin?
    b
    1 reply · 2 participants
  • a

    arnaud.giuliani

    09/26/2018, 7:30 PM
    if you previously used `release()`to drop single definitions, better use now
    scope
    definition tied to the same scope Id
    p
    7 replies · 2 participants
  • a

    arnaud.giuliani

    10/01/2018, 11:45 AM
    use the
    checkModules
    function from
    koin-test
    to check your modules tree
    q
    1 reply · 2 participants
  • e

    elifarley

    10/03/2018, 12:32 PM
    2018-10-03 09:31:10:604 (KOIN)::[i] [PrintLogger] display debug = true
    2018-10-03 09:31:10:616 (KOIN)::[i] [context] create
    2018-10-03 09:31:10:726 (KOIN)::[i] [module] declare Single [name='ISimpleDataSourceFactory',class='jdbc.ISimpleDataSourceFactory']
    2018-10-03 09:31:10:726 (KOIN)::[i] [module] declare Single [name='DataSource',class='javax.sql.DataSource']
    2018-10-03 09:31:10:728 (KOIN)::[i] [module] declare Single [name='ServerConfig',class='org.http4k.server.ServerConfig']
    2018-10-03 09:31:10:728 (KOIN)::[i] [module] declare Single [name='SteelheartRestClient',class='stht.client.SteelheartRestClient']
    2018-10-03 09:31:10:738 (KOIN)::[i] [module] declare Single [name='customer',class='klib.db.SimpleObjectSessionFactory']
    2018-10-03 09:31:10:742 (KOIN)::[i] [module] declare Single [name='CustomerService',class='stht.service.CustomerService']
    2018-10-03 09:31:10:748 (KOIN)::[i] [module] declare Single [name='app.routes',class='kotlin.jvm.functions.Function1']
    2018-10-03 09:31:10:749 (KOIN)::[i] [module] declare Single [name='Http4kServer',class='org.http4k.server.Http4kServer']
    2018-10-03 09:31:10:749 (KOIN)::[i] [modules] loaded 8 definitions
    2018-10-03 09:31:10:749 (KOIN)::[d] [modules] loaded in 53.834704 ms
    2018-10-03 09:31:10:750 (KOIN)::[d] Koin started in 136.243142 ms
    2018-10-03 09:31:10:779 (KOIN)::[i] +-- 'org.http4k.server.Http4kServer' 
    2018-10-03 09:31:10:779 (KOIN)::[d] |-- [Single [name='Http4kServer',class='org.http4k.server.Http4kServer']]
    2018-10-03 09:31:10:784 (KOIN)::[i] |	+-- 'kotlin.jvm.functions.Function1' 
    2018-10-03 09:31:10:795 (KOIN)::[d] |	|-- [Single [name='app.routes',class='kotlin.jvm.functions.Function1']]
    2018-10-03 09:31:10:796 (KOIN)::[i] |	|	+-- 'stht.service.CustomerService' 
    2018-10-03 09:31:10:797 (KOIN)::[d] |	|	|-- [Single [name='CustomerService',class='stht.service.CustomerService']]
    2018-10-03 09:31:10:797 (KOIN)::[i] |	|	|	+-- 'klib.db.SimpleObjectSessionFactory' 
    2018-10-03 09:31:10:797 (KOIN)::[d] |	|	|	|-- [Single [name='customer',class='klib.db.SimpleObjectSessionFactory']]
    2018-10-03 09:31:10:797 (KOIN)::[i] |	|	|	|	+-- 'javax.sql.DataSource' 
    2018-10-03 09:31:10:797 (KOIN)::[d] |	|	|	|	|-- [Single [name='DataSource',class='javax.sql.DataSource']]
    2018-10-03 09:31:10:800 (KOIN)::[i] |	|	|	|	|	+-- 'jdbc.ISimpleDataSourceFactory' 
    2018-10-03 09:31:10:800 (KOIN)::[d] |	|	|	|	|	|-- [Single [name='ISimpleDataSourceFactory',class='jdbc.ISimpleDataSourceFactory']]
    2018-10-03 09:31:10:830 (KOIN)::[e] Error while resolving instance for class 'jdbc.ISimpleDataSourceFactory' - error: org.koin.error.BeanInstanceCreationException: Can't create definition for 'Single [name='ISimpleDataSourceFactory',class='jdbc.ISimpleDataSourceFactory']' due to error :
    		Can't find property 'db.driver'
    		klib.db.DataSourceKitKt$dsModule$1$1.invoke(dataSourceKit.kt:34)
    ➕ 1
    d
    1 reply · 2 participants
  • j

    Jemshit Iskenderov

    10/05/2018, 1:33 PM
    Hi, i have question regarding to Scoping: Desired: Create scope for ViewModel, should be created when ViewModel is created, released in
    ViewModel#onCleared()
    (not Activity lifecycle) Aim: ViewModel injects
    UseCaseA
    and
    UseCaseB
    , and both use cases inject
    RealTimeConnection
    interface. Implementation of
    RealTimeConnection
    injects
    ClassC
    . I want
    RealTimeConnection
    implementation and
    ClassC
    to be created only once in ViewModel scope. I have tried:
    module("app") {
        scope(SCOPE_VM) {
            ClassC()
        }
        scope(SCOPE_VM) { RealTimeConnectionImplementation(get()) as RealTimeConnection }
    
        factory { UseCaseA(get()) }  // parameter is RealTimeConnection
        factory { UseCaseB(get()) }  // parameter is RealTimeConnection
    }
    Question: i can not inject
    UseCaseA
    and
    UseCaseB
    from constructor of ViewModel because scope is created in
    init{}
    block of ViewModel. I can not use
    by inject, get<>
    inside ViewModel. What is the solution? Thanks
    1 reply · 1 participant
  • j

    Jemshit Iskenderov

    10/05/2018, 2:16 PM
    I found i can inject useCases after i create scope using
    by inject()
    if i implement
    KoinComponent
    . Is this the right way?
    t
    3 replies · 2 participants
  • j

    Jason

    10/06/2018, 2:38 PM
    Hello I am a newbie in Koin. Where can I start with Koin ?
    t
    1 reply · 2 participants
  • v

    Vinicius Carvalho

    10/09/2018, 2:35 PM
    Hi there, I'm switching from kodein to koin on my ktor application. Previously I've created an extension function to make the Application class available to
    KodeinAware
    classes to inject it. Is it possible to have access to the
    Application
    instance from my managed instances in koin?
    t
    a
    8 replies · 3 participants
  • r

    rezenebe

    10/10/2018, 9:29 PM
    is there a reason to initiate koin multiple times in a project? calling startKoin() in other modules perhaps?
    t
    2 replies · 2 participants
  • r

    rezenebe

    10/12/2018, 3:13 PM
    val testRemoteRepository by inject<ConfigDatasource>()
    I'm getting an "unresolved reference" on ConfigDataSource which is 95% similar to the example. There is no red or missing dependencies in my code, any idea on where to start debugging this? I was trying to write checkModule Tests, but I can't get that far w/ ConfigDataSource compile time issues
    t
    4 replies · 2 participants
  • r

    rezenebe

    10/12/2018, 10:21 PM
    val remoteDatasourceModule = module {
        single { createOkHttpClient() }
        single { createWebService<ConfigDatasource>(get(), getProperty(DatasourceProperties.SERVER_URL)) }
    
        single { ConfigRepositoryImpl(get()) as ConfigRepository }
    }
    
    object DatasourceProperties {
        const val SERVER_URL = BuildConfig.BASE_URL
    }
    This seems to work just fine when I hardcode the SERVER_URL otherwise i get "Can't find property"
    t
    d
    3 replies · 3 participants
  • a

    Albert

    10/18/2018, 8:48 AM
    What I understand from the documentation, generics are supported only by giving a name to the
    single
    module {
      single("foo") { Repository<Foo>() }
      single("bar") { Repository<Bar>() }
    }
    
    val fooRepo: Repository<Foo>() by inject("foo")
    val barRepo: Repository<Bar>() by inject("bar")
    Is there an alternative that I could use
    inject()
    (without key) instead of making the injector aware what the key should be?
    t
    d
    6 replies · 3 participants
  • e

    Efe

    10/19/2018, 8:08 AM
    Hi guys, probably it’s an easy question but I’m too newbie to koin. How can I inject an android framework created object (like Activity or Fragment) to my presenter layer as a View?
    r
    1 reply · 2 participants
  • c

    cjmartinkoski

    10/25/2018, 7:45 PM
    message has been deleted
    1 reply · 1 participant
Powered by Linen
Title
c

cjmartinkoski

10/25/2018, 7:45 PM
message has been deleted
hi all, do koin have a scope manager that supports concurrent scopes, for example, i'm using CDI request scoped in my web application, koin can replace it?
View count: 2