Skip to content

Commit

Permalink
[Add] Flow CollectResult 확장 함수 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dongx0915 committed Mar 30, 2024
1 parent 6a5991d commit 17abeac
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/com/runnect/runnect/util/extension/FlowExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.runnect.runnect.util.extension

import kotlinx.coroutines.flow.Flow

suspend fun <T> Flow<Result<T>>.collectResult(
onSuccess: (T) -> Unit,
onFailure: (Throwable) -> Unit
) {
collect { result ->
result.fold(onSuccess, onFailure)
}
}

0 comments on commit 17abeac

Please sign in to comment.