ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Follow publication

Let’s build our own simplified version of Koin

Rygel Louv
ProAndroidDev
Published in
7 min readJul 13, 2020

--

Service Locator

Service

interface Service {
val type: KClass<*>
val instance: Any
}

Modules and Declarations

val myModule = module {
// Declare dependencies here...
}
factory { Repository() }
typealias Declaration<T> = () -> T
mod1 + mod2
factory { Repository() }

Module builder

val myModule = module {
factory { UseCase() }
}

The API

factory { UseCase(get()) }
val viewModel: ViewModel = get()

The Module’s get()

The LiteKoin class

The API returns

startLiteKoin {
modules(mod1 + mod2)
}

Declarations are The Key

Text from repository

Last words

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Published in ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Written by Rygel Louv

Software Engineer | Kotlin, Android, Python

Responses (4)

Write a response