Updated on 2026-08-14
This commit is contained in:
parent
f5e56b881e
commit
60dde15698
3 changed files with 24 additions and 6 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