-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35b31d0
commit 089edde
Showing
18 changed files
with
219 additions
and
37 deletions.
There are no files selected for viewing
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
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
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
17 changes: 17 additions & 0 deletions
17
composeApp/src/androidMain/kotlin/com/codingambitions/kmpapp2/MainApplication.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.codingambitions.kmpapp2 | ||
|
||
import android.app.Application | ||
import di.initKoin | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.android.ext.koin.androidLogger | ||
|
||
class MainApplication: Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
initKoin { | ||
androidContext(this@MainApplication) | ||
androidLogger() | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package di | ||
|
||
import HomeRepository | ||
import HomeViewModel | ||
import org.koin.dsl.module | ||
import root.DefaultRootComponent | ||
import root.RootComponent | ||
|
||
fun commonModule() = networkModule() + module { | ||
|
||
single { | ||
HomeRepository(get()) | ||
} | ||
|
||
single { | ||
HomeViewModel(get()) | ||
} | ||
|
||
single<RootComponent> { | ||
DefaultRootComponent( | ||
componentContext = get(), | ||
homeViewModel = get() | ||
) | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package di | ||
|
||
import org.koin.core.context.startKoin | ||
import org.koin.core.module.Module | ||
import org.koin.dsl.KoinAppDeclaration | ||
|
||
fun initKoin( | ||
additionalModules: List<Module> = emptyList(), | ||
appDeclaration: KoinAppDeclaration = {} | ||
) = startKoin { | ||
appDeclaration() | ||
modules(additionalModules + commonModule() + platformModule()) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package di | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.serialization.kotlinx.json.json | ||
import kotlinx.serialization.json.Json | ||
import org.koin.dsl.module | ||
|
||
fun networkModule() = module { | ||
single { | ||
HttpClient { | ||
install(ContentNegotiation) { | ||
json(Json { | ||
prettyPrint = true | ||
ignoreUnknownKeys = true | ||
}) | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package di | ||
|
||
import org.koin.dsl.module | ||
|
||
fun platformModule() = module {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package di | ||
|
||
import com.arkivanov.decompose.ComponentContext | ||
import com.arkivanov.decompose.DefaultComponentContext | ||
import com.arkivanov.essenty.lifecycle.LifecycleRegistry | ||
import org.koin.dsl.module | ||
|
||
val jvmModule = module { | ||
single { LifecycleRegistry() } | ||
single<ComponentContext> { DefaultComponentContext(lifecycle = get<LifecycleRegistry>()) } | ||
} | ||
fun startKoinJvm() = initKoin(additionalModules = listOf(jvmModule)) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package di | ||
|
||
import com.arkivanov.decompose.ComponentContext | ||
import com.arkivanov.decompose.DefaultComponentContext | ||
import com.arkivanov.essenty.lifecycle.LifecycleRegistry | ||
import org.koin.core.Koin | ||
import org.koin.dsl.module | ||
import root.RootComponent | ||
|
||
val iosModule = module { | ||
single { LifecycleRegistry() } | ||
single<ComponentContext> { DefaultComponentContext(lifecycle = get<LifecycleRegistry>()) } | ||
} | ||
|
||
fun initKoinIOS() = initKoin(additionalModules = listOf(iosModule)) | ||
|
||
val Koin.rootComponent: RootComponent | ||
get() = get() | ||
|
||
val Koin.lifecycleRegistry: LifecycleRegistry | ||
get() = get() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package di | ||
|
||
import com.arkivanov.decompose.ComponentContext | ||
import com.arkivanov.decompose.DefaultComponentContext | ||
import com.arkivanov.essenty.lifecycle.LifecycleRegistry | ||
import org.koin.dsl.module | ||
|
||
|
||
val jsModule = module { | ||
single { LifecycleRegistry() } | ||
single<ComponentContext> { DefaultComponentContext(lifecycle = get<LifecycleRegistry>()) } | ||
} | ||
fun startKoinJs() = initKoin(additionalModules = listOf(jsModule)) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Koin.swift | ||
// iosApp | ||
// | ||
// Created by Sunil Kumar on 16/01/24. | ||
// Copyright © 2024 orgName. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import ComposeApp | ||
|
||
|
||
private var _koin: Koin_coreKoin? = nil | ||
var koin: Koin_coreKoin { | ||
return _koin! | ||
} | ||
|
||
|
||
func startKoin() { | ||
let koinApplication = DependencyInjectionKt.doInitKoinIOS() | ||
_koin = koinApplication.koin | ||
} |
Oops, something went wrong.