Skip to content

Commit

Permalink
Merge pull request #98 from matheus-corregiari/hotfix/1.6.1
Browse files Browse the repository at this point in the history
Hotfix/1.6.1
  • Loading branch information
matheus-corregiari authored Jul 8, 2024
2 parents 0207fe2 + 806c286 commit 7903efe
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import androidx.annotation.WorkerThread
import br.com.arch.toolkit.result.DataResult
import br.com.arch.toolkit.result.DataResultStatus
import br.com.arch.toolkit.splinter.Splinter
import br.com.arch.toolkit.splinter.extension.emitData
import br.com.arch.toolkit.splinter.extension.emitError
import br.com.arch.toolkit.splinter.extension.emitLoading
import br.com.arch.toolkit.splinter.extension.invokeCatching
import br.com.arch.toolkit.util.dataResultSuccess
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.catch
Expand Down Expand Up @@ -46,11 +46,15 @@ class MirrorFlow<RESULT : Any> : Strategy<RESULT>() {
requireNotNull(config.flow) { "Flow value mist be set!" }.invoke()
.catch { error -> onError.invoke(error) }
.collect { data ->
executor.logInfo("\t[MirrorFlow] Executed with success, data: $data")
executor.logInfo("\t[MirrorFlow] Emit - Success Data! - $data")
executor.logInfo("\t[MirrorFlow] Received new data, data: $data")
executor.logInfo("\t[MirrorFlow] Emit - Loading Data! - $data")
collector.emitLoading(data)
}
if (executor.error == null) executor.data?.let { collector.emitData(it) }
executor.logInfo("\t[MirrorFlow] Finished flow!")
if (executor.error == null) {
executor.logInfo("\t[MirrorFlow] Emit - Success Data! - ${executor.data}")
collector.emit(dataResultSuccess(executor.data))
}
}.onFailure { error -> onError.invoke(error) }
}

Expand Down

0 comments on commit 7903efe

Please sign in to comment.