Skip to content

Commit

Permalink
- base url for clients is provided using koin
Browse files Browse the repository at this point in the history
  • Loading branch information
rodvar committed Nov 22, 2024
1 parent 43c1acd commit 0db3a0f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import network.bisq.mobile.domain.client.main.user_profile.UserProfileApiGateway
import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade
import network.bisq.mobile.domain.user_profile.UserProfileServiceFacade
import network.bisq.mobile.utils.ByteArrayAsBase64Serializer
import org.koin.core.qualifier.named
import org.koin.dsl.module


Expand All @@ -36,7 +37,12 @@ val clientModule = module {

single<ApplicationBootstrapFacade> { ClientApplicationBootstrapFacade() }

single { ApiRequestService(get(), "10.0.2.2") }
single(named("ApiBaseUrl")) { provideApiBaseUrl() }
single { ApiRequestService(get(), get<String>(named("ApiBaseUrl"))) }
single { UserProfileApiGateway(get()) }
single<UserProfileServiceFacade> { ClientUserProfileServiceFacade(get()) }
}

fun provideApiBaseUrl(): String {
return "10.0.2.2" // Default for Android emulator
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package network.bisq.mobile.domain.di

import org.koin.core.qualifier.named
import org.koin.dsl.module

val iosModule = module {
single<String>(named("ApiBaseUrl")) { provideApiBaseUrl() }
}

fun provideApiBaseUrl(): String {
return "localhost"
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import kotlinx.cinterop.ObjCClass
import kotlinx.cinterop.getOriginalKotlinClass
import network.bisq.mobile.client.di.clientModule
import network.bisq.mobile.domain.di.domainModule
import network.bisq.mobile.domain.di.iosModule
import org.koin.core.Koin
import org.koin.core.context.startKoin
import org.koin.core.parameter.parametersOf
Expand All @@ -14,7 +15,7 @@ class DependenciesProviderHelper {

fun initKoin() {
val instance = startKoin {
modules(listOf(domainModule, presentationModule, clientModule))
modules(listOf(domainModule, presentationModule, clientModule, iosModule))
}

koin = instance.koin
Expand Down

0 comments on commit 0db3a0f

Please sign in to comment.