This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.ktor.application.* | |
import io.ktor.auth.* | |
import io.ktor.response.respondText | |
import io.ktor.routing.* | |
import io.ktor.server.engine.embeddedServer | |
import io.ktor.server.netty.Netty | |
import org.kodein.di.Kodein | |
import org.kodein.di.generic.* | |
import org.kodein.di.ktor.* | |
import org.kodein.di.ktor.controller.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@UseExperimental(ExperimentalStdlibApi::class) | |
inline fun <reified T> generic(): TypeToken<T> = NativeKTypeToken(typeOf<T>()) | |
@UseExperimental(ExperimentalStdlibApi::class) | |
inline fun <reified T: Any> TT(obj: KClass<T>) : TypeToken<T> = NativeKTypeToken(typeOf<T>()) | |
@UseExperimental(ExperimentalStdlibApi::class) | |
inline fun <reified T: Any> TTOf(obj: T) : TypeToken<T> = NativeKTypeToken(typeOf<T>()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bindings | |
val kodeinContainer = Kodein { | |
bind() from singleton { MyController() } | |
constant("creator") with ("Salomon BRYS") | |
constant("maintainer") with ("Romain BOISSELLE") | |
} | |
// Kodein Aware application | |
class DemoApplication(override val kodein: Kodein) | |
: Application(), KodeinAware { | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bindings | |
val diContainer = DI { | |
bind() from singleton { MyController() } | |
constant("creator") with ("Salomon BRYS") | |
constant("maintainer") with ("Romain BOISSELLE") | |
} | |
// Kodein Aware application | |
class DemoApplication(override val di: DI) | |
: Application(), DIAware { | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation("org.kodein:kodein-di-framework-android-x:6.5.5") | |
implementation("org.kodein:kodein-di-generic-jvm:6.5.5") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// API use | |
implementation("org.kodein:kodein-di-core:6.5.5") | |
// Generic, JVM only use | |
implementation("org.kodein:kodein-di-generic-jvm:6.5.5") | |
// Erased, Native, JS or even JVM use | |
implementation("org.kodein:kodein-di-erased:6.5.5") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation("org.kodein:kodein-di-framework-android-x:7.0.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Whatever is your target | |
implementation("org.kodein.di:kodein-di:7.0.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple token auth to avoid flood on my backend API | |
*/ | |
data class Token(val token: String) { | |
fun bearer() = "Bearer $token" | |
} | |
/** | |
* Who's voting? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
kotlin("multiplatform") version "1.3.72" | |
kotlin("plugin.serialization") version "1.3.72" | |
`maven-publish` | |
} | |
kotlin { | |
jvm("android") | |
ios() |
OlderNewer