I'm using this variation of the `NetworkBoundResou...
# android
f
I'm using this variation of the
NetworkBoundResource
. The problem right now is that
Loading
doesn't emit any database updates. Would it be possible to change this in a way that
Loading
emits DB updates while the remote fetch is in progress?
Copy code
flow {
    val data = query().first()

    val flow = if (shouldFetch(data)) {
        emit(Resource.Loading(data))

        try {
            saveFetchResult(fetch())
            onFetchSuccess()
            query().map { Resource.Success(it) }
        } catch (t: Throwable) {
            onFetchFailed(t)
            query().map { Resource.Error(t, it) }
        }
    } else {
        query().map { Resource.Success(it) }
    }
    emitAll(flow)
}