mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-23 02:28:47 +00:00
initialization fixes
This commit is contained in:
parent
6f174cae1d
commit
871b27f37d
@ -10,9 +10,9 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
|
|
||||||
class FlowState<T>(
|
class FlowState<T>(
|
||||||
initial: T,
|
initial: T,
|
||||||
internalScope: CoroutineScope = CoroutineScope(Dispatchers.Main)
|
internalScope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||||
) : MutableState<T>,
|
) : MutableState<T>,
|
||||||
SpecialMutableStateFlow.Default<T>(initial, internalScope) {
|
SpecialMutableStateFlow<T>(initial, internalScope) {
|
||||||
private var internalValue: T = initial
|
private var internalValue: T = initial
|
||||||
override var value: T
|
override var value: T
|
||||||
get() = internalValue
|
get() = internalValue
|
||||||
|
@ -9,11 +9,10 @@ import kotlinx.coroutines.flow.MutableSharedFlow
|
|||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
|
||||||
interface SpecialMutableStateFlow<T> : StateFlow<T>, FlowCollector<T>, MutableSharedFlow<T> {
|
open class SpecialMutableStateFlow<T>(
|
||||||
open class Default<T>(
|
|
||||||
initialValue: T,
|
initialValue: T,
|
||||||
internalScope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
internalScope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||||
) : SpecialMutableStateFlow<T> {
|
) : StateFlow<T>, FlowCollector<T>, MutableSharedFlow<T> {
|
||||||
protected val internalSharedFlow: MutableSharedFlow<T> = MutableSharedFlow(
|
protected val internalSharedFlow: MutableSharedFlow<T> = MutableSharedFlow(
|
||||||
replay = 0,
|
replay = 0,
|
||||||
extraBufferCapacity = 2,
|
extraBufferCapacity = 2,
|
||||||
@ -56,4 +55,3 @@ interface SpecialMutableStateFlow<T> : StateFlow<T>, FlowCollector<T>, MutableSh
|
|||||||
|
|
||||||
override suspend fun collect(collector: FlowCollector<T>) = publicSharedFlow.collect(collector)
|
override suspend fun collect(collector: FlowCollector<T>) = publicSharedFlow.collect(collector)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user