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()
}