Florian
01/30/2021, 10:46 AMLoading
keeps emitting database updates rather than only a single result (first
)?
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)
}
Dominaezzz
01/30/2021, 1:44 PMprintln
all the emissions? (I'm not sure I understand the what you're trying to achieve)Florian
01/30/2021, 3:48 PMFlorian
01/30/2021, 3:48 PMDominaezzz
01/30/2021, 4:13 PMDominaezzz
01/30/2021, 4:20 PMsaveFetchResult
?Florian
01/30/2021, 7:09 PM