0Pricing
Kotlin Multiplatform Academy · Lesson

Inject into ViewModels & Repos

Resolve dependencies cleanly throughout the app.

From Declared to Used

You registered dependencies and started Koin. Now comes the payoff: injecting those objects into your repositories and view models without building them by hand.

Constructor Injection First

The cleanest style is constructor injection: list what a class needs as parameters, and Koin fills them via get() in the module.

single { UserRepository(api = get()) }

All lessons in this course

  1. Declare a Shared Koin Module
  2. single vs factory Scopes
  3. Start Koin on Android & iOS
  4. Inject into ViewModels & Repos
← Back to Kotlin Multiplatform Academy