Hey everyone! :wave: I recently open-sourced Ledg...
# koin
a
Hey everyone! 👋 I recently open-sourced Ledger, a strict clean-architecture KMP reference app (Android, iOS, Desktop), and I wanted to share it here because it relies heavily on the latest Koin features. When building it, I wanted to completely move away from manual DSL wiring and test out the Koin Compiler Plugin for compile-time safety. A few Koin highlights in the project: • 100% Annotation-driven: Using @Single, @Factory, and @KoinViewModel across the domain/UI layers. • Expect/Actual Modules: Using Koin's expect/actual module capabilities for platform-specific DBs (RoomDatabase.Builder) and DataStore initializations. • Nav 3 + Compose Integration: Routing directly binds screens using navigation<NavKey> { ... koinViewModel() }. I also built an IntelliJ plugin (KMP Project Wizard) that generates new projects using this exact Koin-annotated architecture out of the box. I'd love to get feedback from the DI experts in here on the setup! 📱 Reference App: https://github.com/aoreshkov/kmp-ledger 🛠️ IntelliJ Wizard: https://plugins.jetbrains.com/plugin/31786-kmp-project-wizard
a
Hey Atanas, great Job 👏 interested to have your feedback for the migration (dsl -> annotations)
Koin Compiler 1.1 should make the DSL safer to use. The plugin looks around all real call to entry points and includes
a
Thanks Arnaud! One caveat: kmp-ledger has been annotation-first from the start (Koin compiler since 1.0.0), so no DSL→annotations diary — but a few notes from running annotations-only across a 15-module KMP app, and from the 1.1.0 upgrade last week: • The only thing that forced DSL back: no multibinding in annotations. Each feature contributes a
TopLevelDestination
for the nav shell, and two
@Single TopLevelDestination
override each other instead of aggregating — so it's
single(named("posting_top_level"))
+
getAll<T>()
. An annotation-level "contribute to a set" would let me delete the last DSL in the project. • 1.1.0 fixed my cross-module false
KOIN-D001
(expect/actual platform module) — thank you. But the entry-point pass doesn't honour the
providerOnly
flag the plugin sets on a typed DSL
single<T> { ... }
whose lambda builds
T
, so it walks `T`'s constructor. Repro:
class Probe(val a: String, val b: Int)
+
module { single { Probe("x", 1) } }
→ missing
kotlin.String
. Filed as koin-compiler-plugin#83; it's the only reason I still carry
compileSafety = false
on one entry point. • Question: is
@Provided
still expected on cross-module params under 1.1.0? I need it on use-case→repository params because
core:domain
deliberately doesn't include
DataModule
. That was under per-module validation — with entry-point-only validation the assembled closure should see it. Happy to expand on the per-module-validation tradeoff or a couple of smaller papercuts if useful.
a
The only thing that forced DSL back: no multibinding in annotations.
you have `binds`annotation parameter if needed, to pass extra types / also annotation detect bound types automatically
> Question: is
@Provided
still expected on cross-module params under 1.1.0? 1.1.0 should help more and avoid usage of @Provided if it's somewhere in the graph - validation will be consolidated at entry point level (startKoin call)