Skip to content

Commit a8c5fed

Browse files
committed
action {}, eventHandler {} with no debugging name is deprecated
Logs of actions are nearly useless if they have no name. Let's stop making things so convenient that we go blind.
1 parent b91ad6c commit a8c5fed

File tree

75 files changed

+1003
-265
lines changed

Some content is hidden

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

75 files changed

+1003
-265
lines changed

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/MaybeLoadingGatekeeperWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class MaybeLoadingGatekeeperWorkflow<T : Any>(
3232
context: RenderContext
3333
): MayBeLoadingScreen {
3434
context.runningWorker(isLoading.asTraceableWorker("GatekeeperLoading")) {
35-
action {
35+
action("GatekeeperLoading") {
3636
state = it
3737
}
3838
}

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/PerformancePoemWorkflow.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class PerformancePoemWorkflow(
122122
},
123123
"initializing"
124124
) {
125-
action {
125+
action("initializing") {
126126
isLoading.value = false
127127
state = Selected(NO_SELECTED_STANZA)
128128
}
@@ -148,7 +148,7 @@ class PerformancePoemWorkflow(
148148
}
149149
}.asTraceableWorker("EventRepetition")
150150
) {
151-
action {
151+
action("currentStateIsLoading delay") {
152152
(state as? ComplexCall)?.let { currentState ->
153153
// Still repeating the complex call
154154
state = ComplexCall(
@@ -167,7 +167,7 @@ class PerformancePoemWorkflow(
167167
// is already in the state.
168168
}
169169
) {
170-
action {
170+
action("loaded") {
171171
isLoading.value = false
172172
(state as? ComplexCall)?.let { currentState ->
173173
state = Selected(currentState.payload)

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/PerformancePoemsBrowserWorkflow.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ class PerformancePoemsBrowserWorkflow(
5555
StatefulWorkflow<ConfigAndPoems, State, Unit, OverviewDetailScreen<*>>() {
5656

5757
sealed class State {
58-
object Recurse : State()
58+
data object Recurse : State()
5959

6060
// N.B. This state is a smell. We include it to be able to mimic smells
6161
// we encounter in real life. Best practice would be to fold it
6262
// into [NoSelection] at the very least.
63-
object Initializing : State()
63+
data object Initializing : State()
6464
data class ComplexCall(
6565
val payload: Int
6666
) : State()
6767

68-
object NoSelection : State()
68+
data object NoSelection : State()
6969
data class Selected(val poemIndex: Int) : State()
7070
}
7171

@@ -122,7 +122,7 @@ class PerformancePoemsBrowserWorkflow(
122122
props = nextProps,
123123
key = "${nextProps.first},${nextProps.second}",
124124
) {
125-
action {
125+
action("setOutput") {
126126
setOutput(it)
127127
}
128128
}
@@ -134,7 +134,7 @@ class PerformancePoemsBrowserWorkflow(
134134
is Initializing -> {
135135
context.runningWorker(TraceableWorker.from("BrowserInitializing") { Unit }, "init") {
136136
isLoading.value = true
137-
action {
137+
action("onInitialized") {
138138
isLoading.value = false
139139
state = NoSelection
140140
}
@@ -178,7 +178,7 @@ class PerformancePoemsBrowserWorkflow(
178178
// is already in the state.
179179
}
180180
) {
181-
action {
181+
action("onComplexCall") {
182182
isLoading.value = false
183183
(state as? ComplexCall)?.let { currentState ->
184184
state = if (currentState.payload != NO_POEM_SELECTED) {
@@ -229,7 +229,7 @@ class PerformancePoemsBrowserWorkflow(
229229

230230
private fun choosePoem(
231231
index: Int
232-
) = action {
232+
) = action("choosePoem") {
233233
state = if (simulatedPerfConfig.isComplex) {
234234
ComplexCall(payload = index)
235235
} else {

samples/compose-samples/src/main/java/com/squareup/sample/compose/hellocompose/HelloComposeWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object HelloComposeWorkflow : StatefulWorkflow<Unit, State, Nothing, HelloCompos
1919
}
2020
}
2121

22-
private val helloAction = action {
22+
private val helloAction = action("hello") {
2323
state = state.theOtherState()
2424
}
2525

samples/compose-samples/src/main/java/com/squareup/sample/compose/hellocomposebinding/HelloWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object HelloWorkflow : StatefulWorkflow<Unit, State, Nothing, Rendering>() {
2828
val onClick: () -> Unit
2929
) : Screen
3030

31-
private val helloAction = action {
31+
private val helloAction = action("hello") {
3232
state = state.theOtherState()
3333
}
3434

samples/compose-samples/src/main/java/com/squareup/sample/compose/hellocomposeworkflow/ComposeWorkflowImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ internal class ComposeWorkflowImpl<PropsT, OutputT : Any>(
7676
// Compiler bug doesn't let us call Snapshot.EMPTY.
7777
override fun snapshotState(state: State<PropsT, OutputT>): Snapshot = Snapshot.of("")
7878

79-
private fun forwardOutput(output: OutputT) = action { setOutput(output) }
79+
private fun forwardOutput(output: OutputT) = action("forwardOutput") { setOutput(output) }
8080
}

samples/compose-samples/src/main/java/com/squareup/sample/compose/hellocomposeworkflow/HelloWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object HelloWorkflow : StatefulWorkflow<Unit, State, Nothing, ComposeScreen>() {
2626
}
2727
}
2828

29-
private val helloAction = action {
29+
private val helloAction = action("hello") {
3030
state = state.theOtherState()
3131
}
3232

samples/compose-samples/src/main/java/com/squareup/sample/compose/inlinerendering/InlineRenderingWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object InlineRenderingWorkflow : StatefulWorkflow<Unit, Int, Nothing, Screen>()
4040
context: RenderContext
4141
) = ComposeScreen {
4242
Box {
43-
Button(onClick = context.eventHandler { state += 1 }) {
43+
Button(onClick = context.eventHandler("increment") { state += 1 }) {
4444
Text("Counter: ")
4545
AnimatedCounter(renderState) { counterValue ->
4646
Text(counterValue.toString())

samples/compose-samples/src/main/java/com/squareup/sample/compose/nestedrenderings/RecursiveWorkflow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ object RecursiveWorkflow : StatefulWorkflow<Unit, State, Nothing, Screen>() {
7373

7474
override fun snapshotState(state: State): Snapshot? = null
7575

76-
private fun addChild() = action {
76+
private fun addChild() = action("addChild") {
7777
state = state.copy(children = state.children + 1)
7878
}
7979

80-
private fun reset() = action {
80+
private fun reset() = action("reset") {
8181
state = State()
8282
}
8383
}

samples/compose-samples/src/main/java/com/squareup/sample/compose/textinput/TextInputWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object TextInputWorkflow : StatefulWorkflow<Unit, State, Nothing, Rendering>() {
2323
val onSwapText: () -> Unit
2424
) : Screen
2525

26-
private val swapText = action {
26+
private val swapText = action("swapText") {
2727
state = state.copy(showingTextA = !state.showingTextA)
2828
}
2929

0 commit comments

Comments
 (0)