I've an API that returns flow which I'm converting to sharedFlow using shareIn(). I've a use case where I want to reset the cached value in the sharedFlow and force the flow to fetch new data. We've a resetReplayCache()
however it's only available for MutableSharedFlow.
class User(val id: String) {
private val _flow = SharedFlow<Data> by lazy {
Api.observeData(id).map {result-> transformData(result) } . shareIn(scope, timeout, 1)
}
val flow = _flow
fun forceFetchNewData() {
_flow.resetReplayCache()// how can I do this?
}
}
I'd really appreciate some pointers on either converting the shareFlow to mutableSharedFlow or emptying the sharedFlow cache