Skip to content

Commit aa1aa55

Browse files
committed
Renames WorkflowAction.nextState to state
Undoing a crime against nature and common sense. Closes #9
1 parent 686bf96 commit aa1aa55

File tree

34 files changed

+106
-106
lines changed

34 files changed

+106
-106
lines changed

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
@@ -61,7 +61,7 @@ object PoemsBrowserWorkflow :
6161
}
6262

6363
private fun choosePoem(index: SelectedPoem) = action("goToPoem") {
64-
nextState = index
64+
state = index
6565
}
6666

6767
private val clearSelection = choosePoem(-1)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ object AreYouSureWorkflow : StatefulWorkflow<Unit, State, Finished, AlertContain
9595

9696
override fun snapshotState(state: State) = Snapshot.EMPTY
9797

98-
private val maybeQuit = action { nextState = Quitting }
98+
private val maybeQuit = action { state = Quitting }
9999
private val confirmQuit = action { setOutput(Finished) }
100-
private val cancelQuit = action { nextState = Running }
100+
private val cancelQuit = action { state = Running }
101101
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ object HelloBackButtonWorkflow : StatefulWorkflow<Unit, State, Nothing, Renderin
5858
override fun snapshotState(state: State): Snapshot = Snapshot.EMPTY
5959

6060
private val advance = action {
61-
nextState = when (nextState) {
61+
state = when (state) {
6262
Able -> Baker
6363
Baker -> Charlie
6464
Charlie -> Able
6565
}
6666
}
6767

6868
private val retreat = action {
69-
nextState = when (nextState) {
69+
state = when (state) {
7070
Able -> throw IllegalStateException()
7171
Baker -> Able
7272
Charlie -> Baker

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ class DungeonAppWorkflow(
8080
override fun snapshotState(state: State): Snapshot = Snapshot.EMPTY
8181

8282
private fun displayBoards(boards: Map<String, Board>) = action {
83-
nextState = ChoosingBoard(boards.toList())
83+
state = ChoosingBoard(boards.toList())
8484
}
8585

8686
private fun selectBoard(index: Int) = action {
8787
// No-op if we're not in the ChoosingBoard state.
88-
val boards = (nextState as? ChoosingBoard)?.boards ?: return@action
89-
nextState = PlayingGame(boards[index].first)
88+
val boards = (state as? ChoosingBoard)?.boards ?: return@action
89+
state = PlayingGame(boards[index].first)
9090
}
9191
}

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
@@ -100,7 +100,7 @@ class GameSessionWorkflow(
100100

101101
private class StartRunning(val board: Board) : WorkflowAction<State, Nothing> {
102102
override fun Updater<State, Nothing>.apply() {
103-
nextState = Running(board)
103+
state = Running(board)
104104
}
105105
}
106106

@@ -111,7 +111,7 @@ class GameSessionWorkflow(
111111
when (output) {
112112
Vibrate -> vibrate(50)
113113
PlayerWasEaten -> {
114-
nextState = GameOver(board)
114+
state = GameOver(board)
115115
vibrate(20)
116116
vibrate(20)
117117
vibrate(20)
@@ -121,7 +121,7 @@ class GameSessionWorkflow(
121121
}
122122
}
123123

124-
private fun restartGame() = action("restartGame") { nextState = Loading }
124+
private fun restartGame() = action("restartGame") { state = Loading }
125125

126126
private fun vibrate(durationMs: Long) {
127127
@Suppress("DEPRECATION")

samples/dungeon/common/src/main/java/com/squareup/sample/dungeon/AiWorkflow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ class AiWorkflow(
7878

7979
private val updateDirection = action("updateDirection") {
8080
// Rotate 90 degrees.
81-
val newDirection = when (nextState.direction) {
81+
val newDirection = when (state.direction) {
8282
UP -> RIGHT
8383
RIGHT -> DOWN
8484
DOWN -> LEFT
8585
LEFT -> UP
8686
}
8787

88-
nextState = nextState.copy(direction = newDirection)
88+
state = state.copy(direction = newDirection)
8989
}
9090
}
9191

samples/dungeon/common/src/main/java/com/squareup/sample/dungeon/GameWorkflow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ class GameWorkflow(
192192

193193
// Check if AI captured player.
194194
if (newGame.isPlayerEaten) {
195-
nextState = nextState.copy(game = newGame)
195+
state = state.copy(game = newGame)
196196
setOutput(PlayerWasEaten)
197197
} else {
198-
nextState = nextState.copy(game = newGame)
198+
state = state.copy(game = newGame)
199199
output?.let { setOutput(it) }
200200
}
201201
}

samples/dungeon/common/src/main/java/com/squareup/sample/dungeon/PlayerWorkflow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ class PlayerWorkflow(
3939

4040
class StartMoving(private val direction: Direction) : Action() {
4141
override fun Updater<Movement, Nothing>.apply() {
42-
nextState += direction
42+
state += direction
4343
}
4444
}
4545

4646
class StopMoving(private val direction: Direction) : Action() {
4747
override fun Updater<Movement, Nothing>.apply() {
48-
nextState -= direction
48+
state -= direction
4949
}
5050
}
5151
}

samples/dungeon/timemachine-shakeable/src/main/java/com/squareup/sample/timemachine/shakeable/ShakeableTimeMachineWorkflow.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,20 @@ class ShakeableTimeMachineWorkflow<in P, O : Any, out R : Any>(
118118
}
119119

120120
private val onShake = action {
121-
nextState = PlayingBack(Duration.INFINITE)
121+
state = PlayingBack(Duration.INFINITE)
122122
}
123123

124124
private inner class SeekAction(
125125
private val newPosition: Duration
126126
) : WorkflowAction<State, O> {
127127
override fun Updater<State, O>.apply() {
128-
nextState = PlayingBack(newPosition)
128+
state = PlayingBack(newPosition)
129129
}
130130
}
131131

132132
private inner class ResumeRecordingAction : WorkflowAction<State, O> {
133133
override fun Updater<State, O>.apply() {
134-
nextState = Recording
134+
state = Recording
135135
}
136136
}
137137

samples/dungeon/timemachine/src/test/java/com/squareup/sample/timemachine/TimeMachineWorkflowTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TimeMachineWorkflowTest {
4242
val delegateWorkflow = Workflow.stateful<String, Nothing, DelegateRendering>(
4343
initialState = "initial",
4444
render = { state ->
45-
val sink: Sink<String> = makeEventSink { nextState = it }
45+
val sink: Sink<String> = makeEventSink { this.state = it }
4646
DelegateRendering(state, setState = { sink.send(it) })
4747
}
4848
)

0 commit comments

Comments
 (0)