Skip to content

Commit

Permalink
small refactor in SpecialMutableStateFlow
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanusMokrassar committed Dec 4, 2023
1 parent 43e782a commit f6d5035
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@ open class SpecialMutableStateFlow<T>(
)

protected var _value: T = initialValue
@OptIn(InternalCoroutinesApi::class)
override var value: T
get() = _value
set(value) {
doOnChangeAction(value)
}
protected val job = internalSharedFlow.subscribe(internalScope) {
doOnChangeAction(it)
}

override val replayCache: List<T>
get() = publicSharedFlow.replayCache
override val subscriptionCount: StateFlow<Int>
get() = publicSharedFlow.subscriptionCount

@OptIn(InternalCoroutinesApi::class)
override fun compareAndSet(expect: T, update: T): Boolean {
Expand All @@ -63,14 +70,6 @@ open class SpecialMutableStateFlow<T>(
}
}
}
protected val job = internalSharedFlow.subscribe(internalScope) {
doOnChangeAction(it)
}

override val replayCache: List<T>
get() = publicSharedFlow.replayCache
override val subscriptionCount: StateFlow<Int>
get() = publicSharedFlow.subscriptionCount

@ExperimentalCoroutinesApi
override fun resetReplayCache() = publicSharedFlow.resetReplayCache()
Expand Down

0 comments on commit f6d5035

Please sign in to comment.