mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Adds set method to MutableDataSource
This commit is contained in:
parent
98999c754f
commit
b9b0e84704
@ -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 New Issue
Block a user