@@ -13,23 +13,23 @@ fun <Action> emptyEffect(): Effect<Action> = none
13
13
fun <Action > noEffect (): Effect <Action > = none
14
14
15
15
fun <Action , R > Effect<Action>.map (mapFn : (Action ) -> R ): Effect <R > = Effect { this .invoke().map { mapFn(it) } }
16
- fun <Action > Iterable<Effect<Action>>.merge () = Effect { this .map { it.invoke() }.merge() }
17
- fun <Action > Effect<Action>.concatenate (other : Effect <Action >) = Effect { this .invoke().onCompletion { if (it == null ) emitAll(other.invoke()) } }
18
-
19
- @OptIn(ExperimentalCoroutinesApi ::class )
20
- fun <Action > Iterable<Effect<Action>>.concatenate () = Effect { this .map { it.invoke() }.asFlow().flattenConcat() }
21
16
22
17
fun <Action > Action.asEffect (): Effect <Action > = Effect { flowOf(this ) }
23
18
fun <Action > Iterable<Action>.asEffect (): Effect <Action > = Effect { this .asFlow() }
24
19
25
- fun <Action > (() -> Action ).asEffect(): Effect <Action > = Effect { flow { emit(invoke()) } }
26
- fun <Action > (suspend () -> Action ).asEffect(): Effect <Action > = Effect { flow { emit(invoke()) } }
20
+ @OptIn(ExperimentalCoroutinesApi ::class )
21
+ fun <Action > Flow<Iterable<Action>>.concatAsEffect (): Effect <Action > = Effect { this .flatMapConcat { it.asFlow() } }
22
+ fun <Action > Iterable<Flow<Action>>.mergeAsEffect (): Effect <Action > = Effect { this .merge() }
27
23
28
24
fun <Action > Flow<Action>.asEffect (): Effect <Action > = Effect { this }
29
25
26
+ fun <Action > (() -> Action ).asEffect(): Effect <Action > = Effect { flow { emit(invoke()) } }
27
+
28
+ fun <Action > Iterable<Effect<Action>>.merge () = Effect { this .map { it.invoke() }.merge() }
29
+
30
+ fun <Action > Effect<Action>.concatenate (other : Effect <Action >) = Effect { this .invoke().onCompletion { if (it == null ) emitAll(other.invoke()) } }
30
31
@OptIn(ExperimentalCoroutinesApi ::class )
31
- fun <Action > Flow<Iterable<Action>>.concatAsEffect (): Effect <Action > = Effect { this .flatMapConcat { it.asFlow() } }
32
- fun <Action > Iterable<Flow<Action>>.mergeAsEffect (): Effect <Action > = Effect { this .merge() }
32
+ fun <Action > Iterable<Effect<Action>>.concatenate () = Effect { this .map { it.invoke() }.asFlow().flattenConcat() }
33
33
34
34
fun <Action > (() -> Unit ).fireAndForget(): Effect <Action > = Effect { flow { invoke() } } // never emits
35
35
fun <Action > (suspend () -> Unit ).fireAndForget(): Effect <Action > = Effect { flow { invoke() } } // never emits
0 commit comments