reverting unused error emissions

This commit is contained in:
Adam Brown 2022-11-10 23:14:02 +00:00
parent 0020c29426
commit f498840c17
1 changed files with 2 additions and 3 deletions

View File

@ -7,7 +7,7 @@ import app.dapk.st.matrix.common.matrixLog
import kotlinx.coroutines.*
internal class SideEffectFlowIterator(private val logger: MatrixLogger, private val errorTracker: ErrorTracker) {
suspend fun <T> loop(initial: T?, onPost: suspend (Throwable?) -> Unit, onIteration: suspend (T?) -> T?) {
suspend fun <T> loop(initial: T?, onPost: suspend () -> Unit, onIteration: suspend (T?) -> T?) {
var previousState = initial
while (currentCoroutineContext().isActive) {
@ -16,12 +16,11 @@ internal class SideEffectFlowIterator(private val logger: MatrixLogger, private
previousState = withContext(NonCancellable) {
onIteration(previousState)
}
onPost(null)
onPost()
} catch (error: Throwable) {
logger.matrixLog(SYNC, "on loop error: ${error.message}")
errorTracker.track(error, "sync loop error")
delay(10000L)
onPost(error)
}
}
logger.matrixLog(SYNC, "isActive: ${currentCoroutineContext().isActive}")