diff --git a/app/src/main/java/com/runnect/runnect/util/extension/FlowExt.kt b/app/src/main/java/com/runnect/runnect/util/extension/FlowExt.kt new file mode 100644 index 00000000..b640d4f6 --- /dev/null +++ b/app/src/main/java/com/runnect/runnect/util/extension/FlowExt.kt @@ -0,0 +1,12 @@ +package com.runnect.runnect.util.extension + +import kotlinx.coroutines.flow.Flow + +suspend fun Flow>.collectResult( + onSuccess: (T) -> Unit, + onFailure: (Throwable) -> Unit +) { + collect { result -> + result.fold(onSuccess, onFailure) + } +} \ No newline at end of file