mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 18:05:59 +03:00
Adds set method to MutableDataSource
This commit is contained in:
parent
98999c754f
commit
b9b0e84704
1 changed files with 11 additions and 0 deletions
|
@ -25,6 +25,9 @@ interface DataSource<T> {
|
|||
}
|
||||
|
||||
interface MutableDataSource<T> : DataSource<T> {
|
||||
|
||||
suspend fun set(value: T)
|
||||
|
||||
fun post(value: T)
|
||||
}
|
||||
|
||||
|
@ -42,6 +45,10 @@ open class BehaviorDataSource<T>(private val defaultValue: T? = null) : MutableD
|
|||
return mutableFlow
|
||||
}
|
||||
|
||||
override suspend fun set(value: T) {
|
||||
mutableFlow.emit(value)
|
||||
}
|
||||
|
||||
override fun post(value: T) {
|
||||
mutableFlow.tryEmit(value)
|
||||
}
|
||||
|
@ -58,6 +65,10 @@ open class PublishDataSource<T> : MutableDataSource<T> {
|
|||
return mutableFlow
|
||||
}
|
||||
|
||||
override suspend fun set(value: T) {
|
||||
mutableFlow.emit(value)
|
||||
}
|
||||
|
||||
override fun post(value: T) {
|
||||
mutableFlow.tryEmit(value)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue