← к каталогу

📦 Napier/ AAkira

Logging library for Kotlin Multiplatform

Открыть на GitHub ↗обновлён 4мес назад
Звёзды
★ 996
Форки
42
За неделю
—
За месяц
—
Рост %
—
Язык
Kotlin

Установка и запуск

Run background thread

You can use this library on the background thread on iOS using Kotlin.coroutines as native-mt.

  • Define scope
internal val mainScope = SharedScope(Dispatchers.Main)

internal val backgroundScope = SharedScope(Dispatchers.Default)

internal class SharedScope(private val context: CoroutineContext) : CoroutineScope {
    private val job = Job()
    private val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
        println("[Coroutine Exception] $throwable")
    }

    override val coroutineContext: CoroutineContext
        get() = context + job + exceptionHandler
}
  • Usage
backgroundScope.launch {
    suspendFunction()
}

Из README репозитория · полный README на GitHub

Категории

Теги

kotlin-jskotlin-librarykotlin-multiplatformkotlin-native