Skip to content

Latest commit

 

History

History

redukt-koin

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

ReduKt Koin

Maven Central GitHub API reference

ReduKt integration with Koin framework.

Quick start

You have 2 ways to work with Koin here.

The first one depends on global koin instance initialized by startKoin { ... } like this:

fun createStore(): Store<AppState> {
    startKoin {
        single { HttpClient() }
        // ...
    }
    return buildStore {
        // ...
        clousre {
            +GlobalKoinDI
        }
    }
}

fun customMiddleware() = middleware<AppState> {
    val client by koin.inject<HttpClient>()
    // ...
}

The second one allows you to inject specific koin application instance:

fun createStore(): Store<AppState> {
    val koinApp = koinApplication {
        single { HttpClient() }
        // ...
    }
    return buildStore {
        // ...
        clousre {
            +KoinApplicationDI(koinApp)
        }
    }
}

fun customMiddleware() = middleware<AppState> {
    val client by koin.inject<HttpClient>()
    // ...
}