I want to create a Custom Flow class which should be a Hot Flow. So it recommended to create something like below
class ContentFlow(context: Context, initialValue: SomeObject) : StateFlow {
private val _state = MutableStateFlow(initialValue)
override val value: SomeObject
get() = _state.value
override fun compareAndSet(expect: SomeObject, update: SomeObject): Boolean =
_state.compareAndSet(expect, update)
override suspend fun collect(collector: FlowCollector) {
_state.collect(collector)
}
override fun tryEmit(value: SomeObject): Boolean =
_state.tryEmit(value)
override val replayCache: List
get() = _state.replayCache
}