Add operator functions for handling set preferences

This commit is contained in:
arkon
2020-07-25 18:07:10 -04:00
parent e95a5be21d
commit 2dc47352f8
5 changed files with 29 additions and 26 deletions

View File

@@ -27,6 +27,14 @@ fun <T> Preference<T>.asImmediateFlow(block: (value: T) -> Unit): Flow<T> {
.onEach { block(it) }
}
operator fun <T> Preference<Set<T>>.plusAssign(item: T) {
set(get() + item)
}
operator fun <T> Preference<Set<T>>.minusAssign(item: T) {
set(get() - item)
}
@OptIn(ExperimentalCoroutinesApi::class)
class PreferencesHelper(val context: Context) {