Fix network state observer

This commit is contained in:
Koitharu
2022-11-30 09:22:51 +02:00
parent f469369b14
commit 1cbfe017ea
3 changed files with 21 additions and 24 deletions

View File

@@ -5,14 +5,11 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import java.util.concurrent.atomic.AtomicInteger
abstract class MediatorStateFlow<T> : StateFlow<T> {
abstract class MediatorStateFlow<T>(initialValue: T) : StateFlow<T> {
@Suppress("LeakingThis")
private val delegate = MutableStateFlow(initialValue)
private val collectors = AtomicInteger(0)
protected abstract val initialValue: T
final override val replayCache: List<T>
get() = delegate.replayCache