Skip to content

Commit 69f29c3

Browse files
authored
Merge pull request #1362 from BKinya/update-code-snippets-in-tutorials
Thanks again.
2 parents 72b0e22 + 6179d71 commit 69f29c3

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

samples/tutorial/Tutorial1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class TutorialActivity : AppCompatActivity() {
245245
@OptIn(WorkflowExperimentalRuntime::class)
246246
val renderings: Flow<Screen> by lazy {
247247
renderWorkflowIn(
248-
workflow = RootNavigationWorkflow,
248+
workflow = WelcomeWorkflow,
249249
scope = viewModelScope,
250250
savedStateHandle = savedState,
251251
runtimeConfig = RuntimeConfigOptions.ALL

samples/tutorial/Tutorial2.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ At the same time, add a `reportNavigation()` call when creating the `renderings`
255255
scope = viewModelScope,
256256
savedStateHandle = savedState
257257
)
258-
}.reportNavigation()
258+
}.reportNavigation {
259+
Log.i("navigate", it.toString())
260+
}
259261
```
260262

261263
Now when you run the app we'll see the welcome screen again.
@@ -587,8 +589,7 @@ So far it has output `Nothing`.
587589
Define a `BackPressed` object and use it as `TodoListWorkflow`'s output type.
588590
Update `render()` to create an `eventHandler` function to post the new output event.
589591

590-
At the same time, update TodoListScreen with an `onBack` event handler,
591-
and use workflow's handy `View.setBackHandler` function to respond to Android back press events.
592+
At the same time, use workflow's handy `View.setBackHandler` function to respond to Android back press events.
592593
593594
> [!NOTE] `View.setBackHandler` is implemented via
594595
> [OnBackPressedCallback](https://developer.android.com/reference/androidx/activity/OnBackPressedCallback)
@@ -614,7 +615,7 @@ object TodoListWorkflow : StatefulWorkflow<ListProps, State, BackPressed, TodoLi
614615
return TodoListScreen(
615616
username = renderProps.username,
616617
todoTitles = titles,
617-
onBackPressed = { context.actionSink.send(onBack()) }
618+
onBackPressed = context.eventHandler("onBackPressed") { setOutput(BackPressed) }
618619
)
619620
}
620621
```

samples/tutorial/Tutorial3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ object TodoListWorkflow : StatefulWorkflow<ListProps, State, BackPressed, List<S
221221
TodoListScreen(
222222
username = renderProps.username,
223223
todoTitles = titles,
224-
onBackPressed = { context.actionSink.send(onBack()) }
224+
onBackPressed = context.eventHandler("onBackPressed") { setOutput(BackPressed) }
225225
)
226226
)
227227
}

samples/tutorial/Tutorial4.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ object TodoListWorkflow : StatefulWorkflow<ListProps, State, Output, TodoListScr
137137
onRowPressed = context.eventHandler("onRowPressed") { index ->
138138
// Tell our parent that a todo item was selected.
139139
setOutput(TodoSelected(index))
140-
},
141-
onBackPressed = { context.actionSink.send(reportBackPress) },
140+
}
142141
)
143142
}
144143
}
@@ -227,7 +226,7 @@ object TodoNavigationWorkflow : StatefulWorkflow<TodoProps, State, Back, List<Sc
227226
return listOf(todoListScreen)
228227
}
229228

230-
private fun requestExit() = action("requestExit") {
229+
private fun goBack() = action("requestExit") {
231230
setOutput(Back)
232231
}
233232

0 commit comments

Comments
 (0)