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
  • d

    Dennis Schröder

    10/16/2019, 9:08 PM
    Is it possible to iterate over all declared dependencies from an specific module?
    a
    • 2
    • 2
  • c

    Claudiu M

    10/18/2019, 10:52 AM
    In terms of scoping with Koin, after starting Koin in application.onCreate, does it make sense in trying to achieve scoped dependencies by loading(onCreate)/unloading(onDestroy) new modules on the fly in Activities/Fragments. For example, in Activity A, I would load/unload modules (A1,A2) and in FragmentB and FragmentC (that would be presented in Activity A) I would load/unload modules (B1,B2 for FragmentB) as well as (C1,C2 for FragmentC). My understanding is that all definitions in A1/A2 would be available and shared between A,B and C(meaning a single { } would be the same between A,B,C). Is that correct?
    a
    • 2
    • 2
  • k

    Kevin Luke

    10/19/2019, 2:55 AM
    Hello, how do I use different injections for tests? Similar to spring profiles. I'm trying to start a test with a different set of components than my main app. (Local db, etc) I've tried the override=true flag, but it's not doing anything. My production components are always called
    d
    • 2
    • 1
  • p

    poohbar

    10/20/2019, 3:42 PM
    I tried adding
    createdAtStart = true
    to the
    single
    declaration but it still does not get created at startup.
    h
    • 2
    • 1
  • s

    streetsofboston

    10/25/2019, 5:39 AM
    For Android, Dagger is now recommended by Google... https://developer.android.com/training/dependency-injection#choosing-right-di-tool
    🤔 3
    s
    v
    p
    • 4
    • 4
  • c

    Casey Brooks

    10/25/2019, 6:46 PM
    I think the rationale would be that larger apps have a larger number of dependencies that will be injected throughout. A service locator, or a runtime DI library, would necessarily need to know about each and every dependency available throughout the lifetime of the app in some ever-growing singleton object. In contrast, Dagger generates code and doesn’t really “hold on” to anything; it simply executes generated code whenever injection is requested, but it doesn’t need to hold in memory some kind of “binding object” in order to be able to inject stuff
    s
    • 2
    • 1
  • o

    Ove Stoerholt

    10/29/2019, 1:16 PM
    Question: When creating a module definition Koin complaints when having more than 5 parameters. Is this a limitation in the current version? If so; Why?
    s
    • 2
    • 3
  • s

    Saiedmomen

    11/03/2019, 7:36 PM
    Can someone please explain why everyone says that koin is a service locator and Dagger is a 'true' DI? I don't see any semantic differences in module definitions and what I understand from service locators is completely different from koin(sth like androids
    context.getSystemService
    )
    e
    a
    • 3
    • 5
  • c

    Casey Brooks

    11/15/2019, 3:22 PM
    If you’re looking to make a new docs site, I would encourage you to check out Orchid. I’ve been creating it specifically for docs like Koin, and I would be more than happy to work with you to get it set up. Orchid can do your wikis, integrates with Dokka, and much more https://github.com/javaeden/orchid
    a
    • 2
    • 1
  • h

    Hexa

    11/16/2019, 11:59 AM
    can Koin inject some named parameters in a constructor like this
    class Testclass @Inject constructor(
        @Named("some_name") name: String)
    ?
    a
    • 2
    • 1
  • a

    avolkmann

    11/19/2019, 6:10 PM
    Also, how can I use koin before starting the ktor server in my test?
    a
    • 2
    • 1
  • a

    arnaud.giuliani

    11/21/2019, 9:04 AM
    Incoming new stuffs guys 🎉
    👏 2
    👌 3
    🎉 1
    c
    • 2
    • 3
  • t

    tieskedh

    11/27/2019, 12:13 PM
    Question, I have multiple modules, both pure-kotlin and Android. My idea was to have all the modules load a service-provider wich provides a Koin-module. Therefor, I only need to create the Modules. I want to do as much as possible in Kotlin-only modules. The simplest way to do this is by using kotlin-core everywhere with the exception of the base-app where I use those modules... Is this correct and is this possible?
    a
    • 2
    • 3
  • s

    sebastien.rouif

    11/27/2019, 3:43 PM
    Is there a notion a
    Reusable
    the same way Dagger has ? I can’t find it, would anyone be interested ? many times I don’t really need singletons but I don’t need to create a new instance either
    z
    a
    • 3
    • 12
  • t

    tieskedh

    11/28/2019, 9:20 AM
    is it possible to merge modules without starting a koin?
    a
    • 2
    • 3
  • g

    g4sarma

    11/29/2019, 8:26 PM
    And seem to be having an issue creating an instance
    org.koin.core.error.InstanceCreationException: Could not create instance for [type:Factory,primary_type:'com.gaurav.koin2.PaymentViewModel']
    c
    • 2
    • 1
  • g

    g4sarma

    11/29/2019, 8:32 PM
    #koin any idea what could be wrong ?
    a
    • 2
    • 4
  • v

    voben

    11/30/2019, 12:56 AM
    @g4sarma What does your
    PaymentViewModel
    look like? My guess is it has a dependency that Koin doesn’t about. So that’s why Koin cannot create it.
    PaymentViewModel(*Koin doesnt know about this dependency*))
    g
    f
    • 3
    • 2
  • v

    voben

    11/30/2019, 7:04 AM
    What’s the difference between retrieving an instance of a viewmodel by using
    getViewModel
    and
    get
    ?
    e
    • 2
    • 2
  • t

    tieskedh

    12/02/2019, 11:33 AM
    Is it intentional that fragment accepts Qualifier? https://github.com/InsertKoinIO/koin/blob/develop/koin-projects/koin-androidx-fragment/src/main/java/org/koin/androidx/fragment/dsl/ModuleExt.kt
    a
    • 2
    • 2
  • o

    Ofir Bar

    12/02/2019, 2:59 PM
    hi all, This is a general question. How is Koin not generating code? I need to learn more about how it works. Compared to dagger which does generate code.
    v
    • 2
    • 2
  • o

    Ofir Bar

    12/02/2019, 6:45 PM
    Following your post lead to Martin Fowler. If I get this right, it means that Koin have a built in parser that can understand Koin DSL, at run time, and just execute it like Kotlin code. Am I right?
    c
    • 2
    • 2
  • j

    Jay

    12/03/2019, 11:35 PM
    In other words, is Koin “single” definition threadsafe?
    h
    • 2
    • 3
  • f

    Fav123

    12/06/2019, 3:25 PM
    In this case KoinRepositoryLetters depends on KoinRepoA(), KoinRepoB(), KoinRepoC(), which all take a ServiceA, ServiceB and ServiceC The error I get is that the bean definition for KoinRepoA() is not found
    Untitled
    b
    • 2
    • 17
  • h

    Hexa

    12/11/2019, 8:34 AM
    What's the difference between single and singleby here https://github.com/InsertKoinIO/getting-started-koin-ktor/blob/master/src/main/kotlin/org/koin/sample/HelloAppModule.kt#L8
    d
    a
    • 3
    • 5
  • r

    Rafal

    12/13/2019, 12:15 PM
    Just wanted to point out that https://start.insert-koin.io/#/getting-started/modules-definitions is down
    a
    • 2
    • 2
  • g

    George Pandian

    12/18/2019, 5:59 AM
    Hi Koin community, First of all thanks for the amazing Koin solution and apologies for posting basic (if not stupid 😃) questions here. I am considering using Koin in production app and before doing that I would love to get a clarity on the below to see a bigger picture in moving confidently for the migration. Our prod code base is huge. We are using dagger for DI and it also has multiple modules. 1. Migrating to Koin in our project has to be done in step by step process so can I use koin and dagger parallelly in same project ? 2. If yes how do I use koin module inside a dagger component and dagger module inside a Koin component during the period of migration ? 3. Is it safe to use Koin in big scale and multi module project or is there any pitfalls that I should be aware of based on your experiences ? Thanks in advance and any help or advice would be appreciated.
    ➕ 1
    a
    • 2
    • 11
  • a

    arnaud.giuliani

    12/18/2019, 8:40 AM
    try to detach about Dagger and its complexity as much as possible
    g
    • 2
    • 3
  • g

    George Pandian

    12/18/2019, 10:57 AM
    Good way to demonstrate to team as a POC 👍
    a
    • 2
    • 1
  • c

    Casey Brooks

    12/18/2019, 6:02 PM
    Is it possible to inject a ViewModel into a custom View class?
    l
    • 2
    • 3
Powered by Linen
Title
c

Casey Brooks

12/18/2019, 6:02 PM
Is it possible to inject a ViewModel into a custom View class?
l

LeoColman

12/18/2019, 6:03 PM
I don't think it's ever good to inject a viewmodel in a view
It's usually done in Fragments and Activities, right? Why do you need to do it for a view?
c

Casey Brooks

12/18/2019, 6:06 PM
I’m wanting to draw on a canvas, with parameters for drawing provided by a ViewModel. I’m still trying to figure out how to properly use ViewModels, so I appreciate the tips
View count: 6