Use `asFlow` from BaseConfig

This commit is contained in:
Ensar Sarajčić 2023-09-28 13:17:17 +02:00
parent 1e1dacf7be
commit ee7780f9e7
2 changed files with 1 additions and 7 deletions

View File

@ -2,11 +2,7 @@ package com.simplemobiletools.flashlight.helpers
import android.content.Context
import android.graphics.Color
import com.simplemobiletools.commons.extensions.sharedPreferencesCallback
import com.simplemobiletools.commons.helpers.BaseConfig
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filterNotNull
import kotlin.reflect.KProperty0
class Config(context: Context) : BaseConfig(context) {
companion object {
@ -66,6 +62,4 @@ class Config(context: Context) : BaseConfig(context) {
var sleepInTS: Long
get() = prefs.getLong(SLEEP_IN_TS, 0)
set(sleepInTS) = prefs.edit().putLong(SLEEP_IN_TS, sleepInTS).apply()
private fun <T> KProperty0<T>.asFlow(): Flow<T> = prefs.run { sharedPreferencesCallback { this@asFlow.get() } }.filterNotNull()
}

View File

@ -9,7 +9,7 @@ androidx-lifecycle = "2.7.0-alpha02"
#EventBus
eventbusVersion = "3.3.1"
#Simple tools
simple-commons = "f87e960171"
simple-commons = "13f995cb51"
#Compose
composeActivity = "1.8.0-rc01"
compose = "1.6.0-alpha06"