Skip to content

Commit 12bfb12

Browse files
authored
Merge pull request #81 from square/rjrjr/props-to-actions
Gives WorkflowAction access to props.
2 parents 77c9d21 + 935265b commit 12bfb12

File tree

67 files changed

+375
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+375
-363
lines changed

samples/containers/app-poetry/src/main/java/com/squareup/sample/poetryapp/PoemListWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object PoemListWorkflow : StatelessWorkflow<List<Poem>, Int, PoemListRendering>(
2727

2828
override fun render(
2929
props: List<Poem>,
30-
context: RenderContext<Nothing, Int>
30+
context: RenderContext<List<Poem>, Nothing, Int>
3131
): PoemListRendering {
3232
// A sink that emits the given index as the result of this workflow.
3333
val sink = context.makeEventSink { index: Int -> setOutput(index) }

samples/containers/app-poetry/src/main/java/com/squareup/sample/poetryapp/PoemsBrowserWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object PoemsBrowserWorkflow :
4040
override fun render(
4141
props: List<Poem>,
4242
state: SelectedPoem,
43-
context: RenderContext<SelectedPoem, Nothing>
43+
context: RenderContext<List<Poem>, SelectedPoem, Nothing>
4444
): OverviewDetailScreen {
4545
val poems: OverviewDetailScreen =
4646
context.renderChild(PoemListWorkflow, props) { selected -> choosePoem(selected) }

samples/containers/hello-back-button/src/main/java/com/squareup/sample/hellobackbutton/AreYouSureWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object AreYouSureWorkflow : StatefulWorkflow<Unit, State, Finished, AlertContain
5252
override fun render(
5353
props: Unit,
5454
state: State,
55-
context: RenderContext<State, Finished>
55+
context: RenderContext<Unit, State, Finished>
5656
): AlertContainerScreen<*> {
5757
val ableBakerCharlie = context.renderChild(HelloBackButtonWorkflow, Unit) { noAction() }
5858

samples/containers/hello-back-button/src/main/java/com/squareup/sample/hellobackbutton/HelloBackButtonWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object HelloBackButtonWorkflow : StatefulWorkflow<Unit, State, Nothing, Renderin
4646
override fun render(
4747
props: Unit,
4848
state: State,
49-
context: RenderContext<State, Nothing>
49+
context: RenderContext<Unit, State, Nothing>
5050
): Rendering {
5151
return Rendering(
5252
message = "$state",

samples/containers/poetry/src/main/java/com/squareup/sample/poetry/PoemWorkflow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object PoemWorkflow : StatefulWorkflow<Poem, Int, ClosePoem, OverviewDetailScree
5656
override fun render(
5757
props: Poem,
5858
state: Int,
59-
context: RenderContext<Int, ClosePoem>
59+
context: RenderContext<Poem, Int, ClosePoem>
6060
): OverviewDetailScreen {
6161
val previousStanzas: List<StanzaRendering> =
6262
if (state == -1) emptyList()
@@ -105,7 +105,7 @@ object PoemWorkflow : StatefulWorkflow<Poem, Int, ClosePoem, OverviewDetailScree
105105
sink.writeInt(state)
106106
}
107107

108-
private sealed class Action : WorkflowAction<Int, ClosePoem> {
108+
private sealed class Action : WorkflowAction<Poem, Int, ClosePoem> {
109109
object ClearSelection : Action()
110110
object SelectPrevious : Action()
111111
object SelectNext : Action()

samples/containers/poetry/src/main/java/com/squareup/sample/poetry/StanzaListWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object StanzaListWorkflow : StatelessWorkflow<Poem, Int, StanzaListRendering>()
2929

3030
override fun render(
3131
props: Poem,
32-
context: RenderContext<Nothing, Int>
32+
context: RenderContext<Poem, Nothing, Int>
3333
): StanzaListRendering {
3434
// A sink that emits the given index as the result of this workflow.
3535
val sink = context.makeEventSink { index: Int -> setOutput(index) }

samples/containers/poetry/src/main/java/com/squareup/sample/poetry/StanzaWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object StanzaWorkflow : StatelessWorkflow<Props, Output, StanzaRendering>() {
4141

4242
override fun render(
4343
props: Props,
44-
context: RenderContext<Nothing, Output>
44+
context: RenderContext<Props, Nothing, Output>
4545
): StanzaRendering {
4646
with(props) {
4747
val sink: Sink<Output> = context.makeEventSink { setOutput(it) }

samples/dungeon/app/src/main/java/com/squareup/sample/dungeon/DungeonAppWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class DungeonAppWorkflow(
5454
override fun render(
5555
props: Props,
5656
state: State,
57-
context: RenderContext<State, Nothing>
57+
context: RenderContext<Props, State, Nothing>
5858
): AlertContainerScreen<Any> = when (state) {
5959

6060
LoadingBoardList -> {

samples/dungeon/app/src/main/java/com/squareup/sample/dungeon/GameSessionWorkflow.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class GameSessionWorkflow(
6565
override fun render(
6666
props: Props,
6767
state: State,
68-
context: RenderContext<State, Nothing>
68+
context: RenderContext<Props, State, Nothing>
6969
): AlertContainerScreen<Any> = when (state) {
7070

7171
Loading -> {
@@ -98,8 +98,8 @@ class GameSessionWorkflow(
9898

9999
override fun snapshotState(state: State): Snapshot = Snapshot.EMPTY
100100

101-
private class StartRunning(val board: Board) : WorkflowAction<State, Nothing> {
102-
override fun Updater<State, Nothing>.apply() {
101+
private class StartRunning(val board: Board) : WorkflowAction<Props, State, Nothing> {
102+
override fun Updater<Props, State, Nothing>.apply() {
103103
state = Running(board)
104104
}
105105
}

samples/dungeon/app/src/main/java/com/squareup/sample/dungeon/TimeMachineAppWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class TimeMachineAppWorkflow(
4343

4444
override fun render(
4545
props: BoardPath,
46-
context: RenderContext<Nothing, Nothing>
46+
context: RenderContext<BoardPath, Nothing, Nothing>
4747
): ShakeableTimeMachineRendering {
4848
val propsFactory = PropsFactory { recording ->
4949
Props(paused = !recording)

0 commit comments

Comments
 (0)