Skip to content

Commit 62d9b13

Browse files
committed
update readme with differences
1 parent face539 commit 62d9b13

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ loostly based on [Toggl's Android implementation](https://github.com/toggl/kompo
88
|---------------|--------|:----------:|
99
| _latest_ | 1.9.10 | 1.7.3 |
1010

11+
## © Differences from Toggl's komposable-architecture
12+
* Kotlin Multiplatform support for use in KMM projects
13+
* The `Effect` interface is based on `Flows` instead of suspending functions
14+
* Removal of `Subscriptions` and supporting long running running and cancellation
15+
* Addition of `ScopedActions` for providing scopes for limiting the scope of long running effects
16+
* An improved `MutableStateFlowStore` send function with support for buffering and batching actions.
17+
* Minor name changes to more closely match the original Swift implementation
18+
1119
## © Licence
1220

1321
```

kmposable-core/src/commonMain/kotlin/com/labosu/kmposable/Effect.kt

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ fun <Action> emptyEffect(): Effect<Action> = none
1313
fun <Action> noEffect(): Effect<Action> = none
1414

1515
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() }
2116

2217
fun <Action> Action.asEffect(): Effect<Action> = Effect { flowOf(this) }
2318
fun <Action> Iterable<Action>.asEffect(): Effect<Action> = Effect { this.asFlow() }
2419

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() }
2723

2824
fun <Action> Flow<Action>.asEffect(): Effect<Action> = Effect { this }
2925

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()) } }
3031
@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() }
3333

3434
fun <Action> (() -> Unit).fireAndForget(): Effect<Action> = Effect { flow { invoke() } } //never emits
3535
fun <Action> (suspend () -> Unit).fireAndForget(): Effect<Action> = Effect { flow { invoke() } } //never emits

0 commit comments

Comments
 (0)