Skip to content

Commit

Permalink
bump koin and ksp, use KoinApplication composable on desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 committed Sep 25, 2023
1 parent aa89aa7 commit 706bfbc
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import io.github.aakira.napier.Napier
import java.util.logging.Level
import java.util.logging.SimpleFormatter
import java.util.logging.StreamHandler
import org.koin.core.context.startKoin
import org.koin.compose.KoinApplication
import org.koin.core.logger.Level as KoinLoggerLevel
import org.koin.core.logger.PrintLogger
import org.koin.dsl.KoinAppDeclaration

fun main() {
Napier.base(
Expand All @@ -27,7 +28,7 @@ fun main() {
),
)

startKoin {
val koinApplication: KoinAppDeclaration = {
logger(PrintLogger(level = KoinLoggerLevel.DEBUG))

modules(
Expand All @@ -41,16 +42,18 @@ fun main() {
onCloseRequest = ::exitApplication,
title = "KmpViewModel Compose Multiplatform",
) {
AppTheme {
NavHost(
startRoute = SearchPhotoRoute,
destinations = koinInjectSetMultibinding(AllDestinationsQualifier),
destinationChangedCallback = remember {
{
println("Destination changed: $it")
}
},
)
KoinApplication(application = koinApplication) {
AppTheme {
NavHost(
startRoute = SearchPhotoRoute,
destinations = koinInjectSetMultibinding(AllDestinationsQualifier),
destinationChangedCallback = remember {
{
println("Destination changed: $it")
}
},
)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion feature_photo_detail_shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ val coroutinesVersion = "1.7.3"
val kmpViewModel = "0.4.1-SNAPSHOT"
val koinVersion = "3.5.0"
val koinKspVersion = "1.3.0"
val koinComposeVersion = "1.0.4"
val koinComposeVersion = "1.1.0"
val arrowKtVersion = "1.2.0"

kotlin {
Expand Down
2 changes: 1 addition & 1 deletion feature_search_photo_shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ val coroutinesVersion = "1.7.3"
val kmpViewModel = "0.4.1-SNAPSHOT"
val koinVersion = "3.5.0"
val koinKspVersion = "1.3.0"
val koinComposeVersion = "1.0.4"
val koinComposeVersion = "1.1.0"
val arrowKtVersion = "1.2.0"

kotlin {
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin = "1.9.0"
kotlin = "1.9.10"
kotlinx-collections-immutable = "0.3.5"
kotlinx-coroutines = "1.7.3"
kotlinx-atomicfu = "0.22.0"
Expand Down Expand Up @@ -30,9 +30,9 @@ androidx-savedstate = "1.2.1"

uri = "0.0.14"
flow-ext = "0.7.1"
koin-core = "3.4.3"
koin-compose = "1.0.4"
uuid = "0.8.0"
koin-core = "3.5.0"
koin-compose = "1.1.0"
uuid = "0.8.1"

kmp-viewmodel = "0.4.1-SNAPSHOT"
khonshu = "0.16.1"
Expand All @@ -41,7 +41,7 @@ inject = "1"
dagger = "2.48"
anvil = "2.4.7"
renderer = "0.13.0"
ksp = "1.9.0-1.0.13"
ksp = "1.9.10-1.0.13"
kotlinpoet = "1.14.2"
auto-service = "1.1.1"
auto-service-ksp = "1.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import com.hoc081098.compose_multiplatform_kmpviewmodel_sample.koin_utils.defaultMapMultibindingQualifier
import com.hoc081098.compose_multiplatform_kmpviewmodel_sample.koin_utils.getMapMultibinding
import org.koin.compose.LocalKoinScope
import org.koin.compose.getKoinScope
import org.koin.core.qualifier.StringQualifier
import org.koin.core.scope.Scope

@Composable
inline fun <reified K, reified V> koinInjectMapMultibinding(
qualifier: StringQualifier = defaultMapMultibindingQualifier<K, V>(),
scope: Scope = LocalKoinScope.current,
scope: Scope = getKoinScope(),
): Map<K, V> = remember(scope, qualifier) {
scope.getMapMultibinding(qualifier = qualifier)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import com.hoc081098.compose_multiplatform_kmpviewmodel_sample.koin_utils.defaultSetMultibindingQualifier
import com.hoc081098.compose_multiplatform_kmpviewmodel_sample.koin_utils.getSetMultibinding
import org.koin.compose.LocalKoinScope
import org.koin.compose.getKoinScope
import org.koin.core.qualifier.StringQualifier
import org.koin.core.scope.Scope

@Composable
inline fun <reified V> koinInjectSetMultibinding(
qualifier: StringQualifier = defaultSetMultibindingQualifier<V>(),
scope: Scope = LocalKoinScope.current,
scope: Scope = getKoinScope(),
): Set<V> = remember(scope, qualifier) {
scope.getSetMultibinding(qualifier = qualifier)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.hoc081098.compose_multiplatform_kmpviewmodel_sample.navigation.rememb
import com.hoc081098.kmp.viewmodel.Closeable
import org.koin.compose.getKoin
import org.koin.core.Koin
import org.koin.core.annotation.KoinInternalApi
import org.koin.core.module.Module

/**
Expand Down Expand Up @@ -40,6 +41,7 @@ inline fun rememberKoinModulesForRoute(
return compositionKoinModuleLoader.loadedState
}

@OptIn(KoinInternalApi::class)
@PublishedApi
internal class CompositionKoinModuleLoader(
private val modules: List<Module>,
Expand Down

0 comments on commit 706bfbc

Please sign in to comment.