We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c230e0a commit 540ffffCopy full SHA for 540ffff
app/src/main/java/com/monstarlab/arch/extensions/UseCaseExtensions.kt
@@ -33,6 +33,15 @@ inline fun <T> safeFlow(
33
}
34
35
36
+fun <T> observableFlow(block: suspend FlowCollector<T>.() -> Unit): Flow<UseCaseResult<T>> = flow(block)
37
+ .catch { exception ->
38
+ Timber.e(exception)
39
+ UseCaseResult.Error(exception.toError())
40
+ }
41
+ .map {
42
+ UseCaseResult.Success(it)
43
44
+
45
fun <T> Flow<UseCaseResult<T>>.onSuccess(action: suspend (T) -> Unit): Flow<UseCaseResult<T>> = transform { result ->
46
if(result is UseCaseResult.Success<T>) {
47
action(result.value)
0 commit comments