Skip to content

Commit c5bb1ee

Browse files
committed
Generics in multi-machine
Refs: #7
1 parent f4f7c78 commit c5bb1ee

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ val commonMain by getting {
133133
- [Welcome](examples/welcome/welcome) - multi-module example of user on-boarding flow
134134
- [Parallel](examples/multi/parallel) - two machines running in parallel in one proxy state
135135
- [Navbar](examples/multi/navbar) - several machines running in proxy state, one of them active at a time
136+
- [Mixed](examples/multi/mixed) - two machines of different gesture/UI system mixed in one state
136137
- [Lifecycle](examples/lifecycle) - track your Android app lifecycle to pause pending operations when the app is suspended
137138

138139
## The basic task - Load-Content-Error
@@ -1258,12 +1259,12 @@ private sealed class MultiGesture {
12581259
data class StringGesture(val data: String) : MultiGesture()
12591260
}
12601261

1261-
private open class TestState : MultiMachineState<MultiGesture, String>() {
1262+
private open class TestState : MultiMachineState<MultiGesture, String, Any, Any>() {
12621263

12631264
private data object IntKey : MachineKey<Int, Int>(null) // Int for gesture and state
12641265
private data object StringKey : MachineKey<String, String>(null) // String for gesture and state
12651266

1266-
override val container: ProxyMachineContainer = AllTogetherMachineContainer(
1267+
override val container: ProxyMachineContainer<Any, Any> = AllTogetherMachineContainer(
12671268
listOf(
12681269
object : MachineInit<Int, Int> {
12691270
override val key: MachineKey<Int, Int> = IntKey
@@ -1310,8 +1311,8 @@ private open class TestState : MultiMachineState<MultiGesture, String>() {
13101311
private data object StringKey : MachineKey<String, String>(null) // String for gesture and state
13111312

13121313
// ... machine init omitted
1313-
1314-
override fun mapUiState(provider: UiStateProvider, changedKey: MachineKey<*, *>?): String {
1314+
1315+
override fun mapUiState(provider: UiStateProvider<Any>, changedKey: MachineKey<*, out Any>?): String {
13151316
val i: Int = provider.getValue(IntKey) // Cast to Int
13161317
val s: String = provider.getValue(StringKey) // Cast to String
13171318
return "$i - $s" // Combined state of any kind you like
@@ -1347,7 +1348,7 @@ private open class TestState : MultiMachineState<MultiGesture, String>() {
13471348
// ... machine init omitted
13481349

13491350
// Our parent gesture is
1350-
override fun mapGesture(parent: MultiGesture, processor: GestureProcessor) = when(parent) {
1351+
override fun mapGesture(parent: MultiGesture, processor: GestureProcessor<Any, Any>) = when(parent) {
13511352
is MultiGesture.IntGesture -> {
13521353
processor.process(IntKey, parent.data) // Int expected
13531354
}

0 commit comments

Comments
 (0)