Updated on 2026-08-14
This commit is contained in:
commit
780686645b
17 changed files with 70 additions and 35 deletions
|
|
@ -2,6 +2,7 @@ package com.tangem.datasource.local.datastore
|
|||
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
|
||||
/**
|
||||
* Runtime store
|
||||
|
|
@ -16,6 +17,8 @@ interface RuntimeStateStore<T> {
|
|||
/** Store [value] */
|
||||
suspend fun store(value: T)
|
||||
|
||||
suspend fun update(function: (T) -> T)
|
||||
|
||||
companion object {
|
||||
|
||||
/**
|
||||
|
|
@ -32,6 +35,10 @@ interface RuntimeStateStore<T> {
|
|||
override suspend fun store(value: T) {
|
||||
flow.value = value
|
||||
}
|
||||
|
||||
override suspend fun update(function: (T) -> T) {
|
||||
flow.update(function)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue