Kermit 1.0
This commit is contained in:
parent
5b5196dbf6
commit
c5f5c7ca8b
14 changed files with 9 additions and 42 deletions
|
@ -1,20 +1,16 @@
|
|||
package com.surrus.peopleinspace
|
||||
|
||||
import android.app.Application
|
||||
import co.touchlab.kermit.Kermit
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.surrus.common.di.initKoin
|
||||
import com.surrus.peopleinspace.di.appModule
|
||||
import org.koin.android.ext.android.inject
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.android.ext.koin.androidLogger
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import org.koin.core.logger.Level
|
||||
import org.osmdroid.config.Configuration
|
||||
import java.io.File
|
||||
|
||||
class PeopleInSpaceApplication : Application() {
|
||||
private val logger: Kermit by inject()
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
@ -32,6 +28,6 @@ class PeopleInSpaceApplication : Application() {
|
|||
modules(appModule)
|
||||
}
|
||||
|
||||
logger.d { "PeopleInSpaceApplication" }
|
||||
Logger.d { "PeopleInSpaceApplication" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@ package com.surrus.peopleinspace.ui
|
|||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.surrus.common.remote.Assignment
|
||||
import com.surrus.common.repository.PeopleInSpaceRepository
|
||||
import com.surrus.common.repository.PeopleInSpaceRepositoryInterface
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
|
|
|
@ -38,7 +38,7 @@ object Versions {
|
|||
|
||||
const val slf4j = "1.7.30"
|
||||
const val logback = "1.2.3"
|
||||
const val kermit = "0.1.9"
|
||||
const val kermit = "1.0.0"
|
||||
|
||||
const val gradleVersionsPlugin = "0.39.0"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.surrus.common.repository
|
||||
|
||||
import co.touchlab.kermit.LogcatLogger
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.squareup.sqldelight.android.AndroidSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
|
@ -14,5 +13,4 @@ actual fun platformModule() = module {
|
|||
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
single<Logger> { LogcatLogger() }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.surrus.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.surrus.common.remote.PeopleInSpaceApi
|
||||
import com.surrus.common.repository.PeopleInSpaceRepository
|
||||
import com.surrus.common.repository.PeopleInSpaceRepositoryInterface
|
||||
|
@ -35,7 +34,6 @@ fun commonModule(enableNetworkLogs: Boolean) = module {
|
|||
single<PeopleInSpaceRepositoryInterface> { PeopleInSpaceRepository() }
|
||||
|
||||
single { PeopleInSpaceApi(get()) }
|
||||
single { Kermit(logger = get()) }
|
||||
}
|
||||
|
||||
fun createJson() = Json { isLenient = true; ignoreUnknownKeys = true }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.surrus.common.repository
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.rickclephas.kmp.nativecoroutines.NativeCoroutineScope
|
||||
import com.squareup.sqldelight.runtime.coroutines.asFlow
|
||||
import com.squareup.sqldelight.runtime.coroutines.mapToList
|
||||
|
@ -22,13 +22,14 @@ interface PeopleInSpaceRepositoryInterface {
|
|||
|
||||
class PeopleInSpaceRepository : KoinComponent, PeopleInSpaceRepositoryInterface {
|
||||
private val peopleInSpaceApi: PeopleInSpaceApi by inject()
|
||||
private val logger: Kermit by inject()
|
||||
|
||||
@NativeCoroutineScope
|
||||
private val coroutineScope: CoroutineScope = MainScope()
|
||||
private val peopleInSpaceDatabase: PeopleInSpaceDatabaseWrapper by inject()
|
||||
private val peopleInSpaceQueries = peopleInSpaceDatabase.instance?.peopleInSpaceQueries
|
||||
|
||||
val logger = Logger.withTag("PeopleInSpaceRepository")
|
||||
|
||||
init {
|
||||
coroutineScope.launch {
|
||||
fetchAndStorePeople()
|
||||
|
@ -77,12 +78,11 @@ class PeopleInSpaceRepository : KoinComponent, PeopleInSpaceRepositoryInterface
|
|||
// The returned will be frozen in Kotlin Native. We can't freeze the Koin internals
|
||||
// so we'll use local variables to prevent the Koin internals from freezing.
|
||||
val api = peopleInSpaceApi
|
||||
val logger = logger
|
||||
return flow {
|
||||
while (true) {
|
||||
val position = api.fetchISSPosition().iss_position
|
||||
emit(position)
|
||||
logger.d("PeopleInSpaceRepository") { position.toString() }
|
||||
logger.d { position.toString() }
|
||||
delay(POLL_INTERVAL)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.surrus.common.repository
|
||||
|
||||
import co.touchlab.kermit.Logger
|
||||
import co.touchlab.kermit.NSLogLogger
|
||||
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
|
@ -12,5 +10,4 @@ actual fun platformModule() = module {
|
|||
val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db")
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
single<Logger> { NSLogLogger() }
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.surrus.common.repository
|
||||
|
||||
import co.touchlab.kermit.CommonLogger
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import org.koin.dsl.module
|
||||
|
||||
|
@ -9,6 +7,4 @@ actual fun platformModule() = module {
|
|||
single {
|
||||
PeopleInSpaceDatabaseWrapper(null)
|
||||
}
|
||||
|
||||
single<Logger> { CommonLogger() }
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.surrus.common.repository
|
||||
|
||||
import co.touchlab.kermit.CommonLogger
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
|
@ -13,6 +11,4 @@ actual fun platformModule() = module {
|
|||
.also { PeopleInSpaceDatabase.Schema.create(it) }
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
|
||||
single<Logger> { CommonLogger() }
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.surrus.common.repository
|
||||
|
||||
import co.touchlab.kermit.Logger
|
||||
import co.touchlab.kermit.NSLogLogger
|
||||
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
|
@ -12,5 +10,4 @@ actual fun platformModule() = module {
|
|||
val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db")
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
single<Logger> { NSLogLogger() }
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.surrus.common.repository
|
||||
|
||||
import co.touchlab.kermit.Logger
|
||||
import co.touchlab.kermit.NSLogLogger
|
||||
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
|
@ -12,5 +10,4 @@ actual fun platformModule() = module {
|
|||
val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db")
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
single<Logger> { NSLogLogger() }
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.surrus.peopleinspace
|
|||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import co.touchlab.kermit.Kermit
|
||||
import co.touchlab.kermit.Logger
|
||||
import coil.ImageLoader
|
||||
import coil.util.CoilUtils
|
||||
import coil.util.DebugLogger
|
||||
|
@ -19,7 +19,6 @@ import org.koin.core.logger.Level
|
|||
import org.koin.dsl.module
|
||||
|
||||
class PeopleInSpaceApplication : Application(), KoinComponent {
|
||||
private val logger: Kermit by inject()
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
@ -33,7 +32,7 @@ class PeopleInSpaceApplication : Application(), KoinComponent {
|
|||
modules(appModule)
|
||||
}
|
||||
|
||||
logger.d { "PeopleInSpaceApplication" }
|
||||
Logger.d { "PeopleInSpaceApplication" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@ package com.surrus.peopleinspace
|
|||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.surrus.common.remote.Assignment
|
||||
import com.surrus.common.repository.PeopleInSpaceRepository
|
||||
import com.surrus.common.repository.PeopleInSpaceRepositoryInterface
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import co.touchlab.kermit.Kermit
|
||||
import com.surrus.common.di.initKoin
|
||||
import com.surrus.common.repository.PeopleInSpaceRepositoryInterface
|
||||
import kotlinx.coroutines.InternalCoroutinesApi
|
||||
|
@ -10,12 +9,10 @@ import react.dom.render
|
|||
|
||||
object AppDependencies : KoinComponent {
|
||||
val repository: PeopleInSpaceRepositoryInterface
|
||||
val logger: Kermit
|
||||
|
||||
init {
|
||||
initKoin()
|
||||
repository = get()
|
||||
logger = get()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue