Marko Kunic
11/15/2021, 2:56 PMarnaud.giuliani
11/22/2021, 5:58 PMinject
• have a dedicated API for that: injectActivity
or something elseholgerbrandl
11/22/2021, 9:06 PMLilly
11/24/2021, 7:22 PMinject
will always try to use inject
from `org.koin.java.KoinJavaComponent.inject`:
val parser: LegacyParser by inject() // Error: No value passed for parameter 'clazz'
I'm using it in a test class of an android project. I have implemented
io.insert-koin:koin-core
io.insert-koin:koin-androidarnaud.giuliani
11/26/2021, 4:35 PMMarko Kunic
11/29/2021, 10:41 AMget()
?Lilly
12/05/2021, 2:09 AMandroidContext
with `KoTest`/ using `checkKoinModules`:
internal class DependencyGraphTest : KoinTest, WordSpec() {
init {
"Koin" should {
"inject my components" {
checkKoinModules(moduleGroupA + moduleGroupB + module {
// mock android context ??
})
}
}
}
}
Lilly
12/05/2021, 2:16 AMcheckKoinModules
was introduced and on github it refers to the checkModules page but there is still the "deprecated" approach explained
[ADDED]
- Introduce new[test]
and DSL to help verify modules - https://insert-koin.io/docs/reference/koin-test/checkmodulescheckKoinModules
[DEPRECATED]
- deprecate old[test]
function, in favor of new APIcheckModules
checkKoinModules
Emirhan Emmez
12/08/2021, 8:52 AMAaron Pradhan
12/10/2021, 7:24 PMby sharedViewModel()
(which is shared with the parent activity, not parent fragment) and by viewModel()
(which I believe creates a new ViewModel instance for the child class). I'm using by viewModels({ requireParentFragment() })
right now, which works fine, but it's not using Koin. I looked at this article, which suggested by viewModel(owner = { ViewModelOwner.Companion.from(requireParentFragment().viewModelStore) })
, but that doesn't work anymore. Similarly, this article suggested by sharedViewModel(from = { requireParentFragment() })
, but the from
keyword doesn't exist anymore.Ruben Quadros
12/11/2021, 3:35 PMfileProperties
in a KMM project?
I have separate android and ios modules and I am not able to access it in ios module.
Using koin version 3.1.4
xxfast
12/14/2021, 12:30 PMgetStateViewModel
is @Deprecated
. How would one inject a view model in a @Composable
with a SavedStateHandle
passed through the params?Patrick Ramsey
12/14/2021, 6:25 PMScott Kruse
12/15/2021, 9:13 PMMarko Kunic
12/16/2021, 4:50 PMxxfast
12/21/2021, 10:13 AMThread 1: EXC_BAD_ACCESS (code=1, address=0x10)
with very little output from the console as to why. Its pointing to this
App`kfun:org.koin.core.module.Module#<get-mappings>(){}kotlin.collections.HashMap<kotlin.String,org.koin.core.instance.InstanceFactory<*>>:
Has anyone encountered this before?coroutinedispatcher
12/26/2021, 10:28 AMCould not resolve io.insert-koin:koin-ktor:"2.2.3".
My setup:
repositories {
mavenCentral()
maven { url = uri("<https://maven.pkg.jetbrains.space/public/p/ktor/eap>") }
}
Then dependencies:
dependencies {
...
implementation ("io.insert-koin:koin-ktor:$koin_version")
}
And in gradle.properties
koin_version= "2.2.3"
Also added in the same file, maybe this is the mistake:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("io.insert-koin:koin-gradle-plugin:2.2.3")
}
}
Ruben Quadros
12/26/2021, 1:55 PMhiltViewModel()
in koin?
I want to get parameters passed to compose navigation using SavedStateHandle
in my viewmodel.Vivek Modi
01/01/2022, 5:25 PMBrian Donovan
01/03/2022, 7:18 PMBrian Donovan
01/03/2022, 7:19 PMMalachi de Ælfweald
01/07/2022, 3:05 PMAidan Low
01/18/2022, 6:33 PMaipok
01/23/2022, 11:56 AMFaceProcessor
that has param from MLKit and I want to override this MlKit
dependency in unit tests with a mock implementation. What is the best way to do this?Matthew Laser
01/27/2022, 10:19 PMby viewModel()
per the docs, I wind up with the following:
java.lang.ClassCastException: com.myapp.MyService cannot be cast to androidx.lifecycle.ViewModelStoreOwner
Doing by viewModel()
inside of Activity
and ComponentActivivty
works fine. I also tried switching from Service
to LifecycleService
with no luck. Any help is appreciated! 🙂Jacob Hughes
02/01/2022, 11:32 AMkotlin.IllegalStateException: KoinApplication has not been started
. When I run the test individual the test passes as expected.
For context each of my test classes extends implements this abstract class:
abstract class KoinTest : KoinComponent {
@BeforeTest
fun beforeTest() {
println("Starting Koin")
startKoin {
printLogger(Level.ERROR)
modules(
module {
single { Log(testing = useMocks) }
},
)
}
}
@AfterTest
fun after() {
stopKoin()
}
}
From my build.gradle
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
classpath("com.android.tools.build:gradle:7.0.4")
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("io.kotest:kotest-assertions-core:5.0.1")
implementation("io.kotest:kotest-framework-engine:5.0.1")
implementation("app.cash.turbine:turbine:0.7.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0-native-mt")
implementation("io.insert-koin:koin-core:3.1.5")
}
}
Has anyone come across any similar issues?bloder
02/07/2022, 2:04 AMmiqbaldc
02/07/2022, 3:01 AM:koin-bridge
module as well?
Related: https://link.medium.com/YNApqhYurnb
To avoid leaking API of such data layer in the application layer. So the modules provider exist in the :koin-bridge
, the koin-bridge
will depend on domain, & data (for concrete implementation of domain repository)
And our application/presentation layer will depends on koin-bridge
instead of depends directly :data
layertim
02/08/2022, 2:27 PMsingle { something}
value outside of a KoinComponent?Peter Hsu
02/12/2022, 9:45 PMPeter Hsu
02/12/2022, 9:45 PMCommonIF.kt
defined in commonMain/interfaces, and a CommonImpl.kt
in androidMain. In iOS, this is implemented in swift by implementing the CommonIF
interface.
Now the question is how I can make this available to Koin when calling startKoin
on in my iosMain code. I have an ModuleLoader
that starts koin and loads the module.
The naive approach that I've been using for testing is to add a constructor parameter to ModuleLoader(val commonImpl: CommonIF)
and provide that in the module by returning this item:
single<CommonIF> { commonImpl }
This breaks the purpose of DI and makes the interface fairly messy and also requires eager loading of these native implementations.
Is there a way to clean this up so that the iOS instance is lazily loaded? Is there a way to define Koin modules in swift so that I could just pass in iOS specific Koin modules to the ModuleLoader
?