Skip to content

Commit 1551901

Browse files
DRAIN_EXCLUSIVE_ACTIONS implementation
1 parent f116b2d commit 1551901

File tree

17 files changed

+1171
-644
lines changed

17 files changed

+1171
-644
lines changed

.github/workflows/kotlin.yml

Lines changed: 408 additions & 276 deletions
Large diffs are not rendered by default.

workflow-config/config-android/src/main/java/com/squareup/workflow1/config/AndroidRuntimeConfigTools.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.squareup.workflow1.config
33
import com.squareup.workflow1.RuntimeConfig
44
import com.squareup.workflow1.RuntimeConfigOptions
55
import com.squareup.workflow1.RuntimeConfigOptions.CONFLATE_STALE_RENDERINGS
6+
import com.squareup.workflow1.RuntimeConfigOptions.DRAIN_EXCLUSIVE_ACTIONS
67
import com.squareup.workflow1.RuntimeConfigOptions.PARTIAL_TREE_RENDERING
78
import com.squareup.workflow1.RuntimeConfigOptions.RENDER_ONLY_WHEN_STATE_CHANGES
89
import com.squareup.workflow1.RuntimeConfigOptions.STABLE_EVENT_HANDLERS
@@ -33,6 +34,10 @@ public class AndroidRuntimeConfigTools {
3334
*
3435
* - `stable` Enables stable event handlers (changes the default value of the `remember`
3536
* parameter of `RenderContext.eventHandler` functions from `false` to `true`)
37+
*
38+
* - `drainExclusive` Enables draining exclusive actions. If we have more actions to process
39+
* that are queued on nodes not affected by the last action application, then we will
40+
* continue to process those actions before another render pass.
3641
*/
3742
@WorkflowExperimentalRuntime
3843
public fun getAppWorkflowRuntimeConfig(): RuntimeConfig {
@@ -48,6 +53,7 @@ public class AndroidRuntimeConfigTools {
4853
"stateChange" -> config.add(RENDER_ONLY_WHEN_STATE_CHANGES)
4954
"partial" -> config.addAll(setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING))
5055
"stable" -> config.add(STABLE_EVENT_HANDLERS)
56+
"drainExclusive" -> config.add(DRAIN_EXCLUSIVE_ACTIONS)
5157
else -> throw IllegalArgumentException("Unrecognized runtime config option \"$it\"")
5258
}
5359
}

workflow-config/config-jvm/src/main/java/com/squareup/workflow1/config/JvmTestRuntimeConfigTools.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.squareup.workflow1.config
33
import com.squareup.workflow1.RuntimeConfig
44
import com.squareup.workflow1.RuntimeConfigOptions
55
import com.squareup.workflow1.RuntimeConfigOptions.CONFLATE_STALE_RENDERINGS
6+
import com.squareup.workflow1.RuntimeConfigOptions.DRAIN_EXCLUSIVE_ACTIONS
67
import com.squareup.workflow1.RuntimeConfigOptions.PARTIAL_TREE_RENDERING
78
import com.squareup.workflow1.RuntimeConfigOptions.RENDER_ONLY_WHEN_STATE_CHANGES
89
import com.squareup.workflow1.RuntimeConfigOptions.STABLE_EVENT_HANDLERS
@@ -35,6 +36,10 @@ public class JvmTestRuntimeConfigTools {
3536
*
3637
* - `stable` Enables stable event handlers (changes the default value of the `remember`
3738
* parameter of `RenderContext.eventHandler` functions from `false` to `true`)
39+
*
40+
* - `drainExclusive` Enables draining exclusive actions. If we have more actions to process
41+
* that are queued on nodes not affected by the last action application, then we will
42+
* continue to process those actions before another render pass.
3843
*/
3944
@OptIn(WorkflowExperimentalRuntime::class)
4045
public fun getTestRuntimeConfig(): RuntimeConfig {
@@ -50,6 +55,7 @@ public class JvmTestRuntimeConfigTools {
5055
"stateChange" -> config.add(RENDER_ONLY_WHEN_STATE_CHANGES)
5156
"partial" -> config.addAll(setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING))
5257
"stable" -> config.add(STABLE_EVENT_HANDLERS)
58+
"drainExclusive" -> config.add(DRAIN_EXCLUSIVE_ACTIONS)
5359
else -> throw IllegalArgumentException("Unrecognized runtime config option \"$it\"")
5460
}
5561
}

workflow-core/api/workflow-core.api

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public final class com/squareup/workflow1/PropsUpdated : com/squareup/workflow1/
164164
public final class com/squareup/workflow1/RuntimeConfigOptions : java/lang/Enum {
165165
public static final field CONFLATE_STALE_RENDERINGS Lcom/squareup/workflow1/RuntimeConfigOptions;
166166
public static final field Companion Lcom/squareup/workflow1/RuntimeConfigOptions$Companion;
167+
public static final field DRAIN_EXCLUSIVE_ACTIONS Lcom/squareup/workflow1/RuntimeConfigOptions;
167168
public static final field PARTIAL_TREE_RENDERING Lcom/squareup/workflow1/RuntimeConfigOptions;
168169
public static final field RENDER_ONLY_WHEN_STATE_CHANGES Lcom/squareup/workflow1/RuntimeConfigOptions;
169170
public static final field STABLE_EVENT_HANDLERS Lcom/squareup/workflow1/RuntimeConfigOptions;
@@ -180,14 +181,22 @@ public final class com/squareup/workflow1/RuntimeConfigOptions$Companion {
180181

181182
public final class com/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions : java/lang/Enum {
182183
public static final field CONFLATE Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
184+
public static final field DEA Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
183185
public static final field DEFAULT Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
184186
public static final field RENDER_ONLY Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
185187
public static final field RENDER_ONLY_CONFLATE Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
188+
public static final field RENDER_ONLY_CONFLATE_DEA Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
186189
public static final field RENDER_ONLY_CONFLATE_PARTIAL Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
190+
public static final field RENDER_ONLY_CONFLATE_PARTIAL_DEA Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
187191
public static final field RENDER_ONLY_CONFLATE_PARTIAL_STABLE Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
192+
public static final field RENDER_ONLY_CONFLATE_PARTIAL_STABLE_DEA Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
188193
public static final field RENDER_ONLY_CONFLATE_STABLE Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
194+
public static final field RENDER_ONLY_DEA Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
195+
public static final field RENDER_ONLY_DEA_STABLE Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
189196
public static final field RENDER_ONLY_PARTIAL Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
197+
public static final field RENDER_ONLY_PARTIAL_DEA Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
190198
public static final field RENDER_ONLY_PARTIAL_STABLE Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
199+
public static final field RENDER_ONLY_PARTIAL_STABLE_DEA Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
191200
public static final field STABLE Lcom/squareup/workflow1/RuntimeConfigOptions$Companion$RuntimeOptions;
192201
public static fun getEntries ()Lkotlin/enums/EnumEntries;
193202
public final fun getRuntimeConfig ()Ljava/util/Set;

workflow-core/src/commonMain/kotlin/com/squareup/workflow1/RuntimeConfig.kt

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ public enum class RuntimeConfigOptions {
6767
@WorkflowExperimentalRuntime
6868
STABLE_EVENT_HANDLERS,
6969

70-
// /**
71-
// * If we have more actions to process that are queued on nodes not affected by the last
72-
// * action application, then we will continue to process those actions before another render
73-
// * pass.
74-
// */
75-
// @WorkflowExperimentalRuntime
76-
// DRAIN_EXCLUSIVE_ACTIONS,
70+
/**
71+
* If we have more actions to process that are queued on nodes not affected by the last
72+
* action application, then we will continue to process those actions before another render
73+
* pass.
74+
*/
75+
@WorkflowExperimentalRuntime
76+
DRAIN_EXCLUSIVE_ACTIONS,
7777
;
7878

7979
public companion object {
@@ -103,31 +103,31 @@ public enum class RuntimeConfigOptions {
103103
CONFLATE(setOf(CONFLATE_STALE_RENDERINGS)),
104104
STABLE(setOf(STABLE_EVENT_HANDLERS)),
105105

106-
// DEA(setOf(DRAIN_EXCLUSIVE_ACTIONS)),
106+
DEA(setOf(DRAIN_EXCLUSIVE_ACTIONS)),
107107
RENDER_ONLY_CONFLATE(setOf(RENDER_ONLY_WHEN_STATE_CHANGES, CONFLATE_STALE_RENDERINGS)),
108108
RENDER_ONLY_PARTIAL(setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING)),
109109

110-
// RENDER_ONLY_DEA(setOf(RENDER_ONLY_WHEN_STATE_CHANGES, DRAIN_EXCLUSIVE_ACTIONS)),
110+
RENDER_ONLY_DEA(setOf(RENDER_ONLY_WHEN_STATE_CHANGES, DRAIN_EXCLUSIVE_ACTIONS)),
111111
RENDER_ONLY_CONFLATE_STABLE(
112112
setOf(RENDER_ONLY_WHEN_STATE_CHANGES, CONFLATE_STALE_RENDERINGS, STABLE_EVENT_HANDLERS)
113113
),
114114
RENDER_ONLY_CONFLATE_PARTIAL(
115115
setOf(RENDER_ONLY_WHEN_STATE_CHANGES, CONFLATE_STALE_RENDERINGS, PARTIAL_TREE_RENDERING)
116116
),
117117

118-
// RENDER_ONLY_CONFLATE_DEA(
119-
// setOf(RENDER_ONLY_WHEN_STATE_CHANGES, CONFLATE_STALE_RENDERINGS, DRAIN_EXCLUSIVE_ACTIONS)
120-
// ),
118+
RENDER_ONLY_CONFLATE_DEA(
119+
setOf(RENDER_ONLY_WHEN_STATE_CHANGES, CONFLATE_STALE_RENDERINGS, DRAIN_EXCLUSIVE_ACTIONS)
120+
),
121121
RENDER_ONLY_PARTIAL_STABLE(
122122
setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING, STABLE_EVENT_HANDLERS)
123123
),
124124

125-
// RENDER_ONLY_PARTIAL_DEA(
126-
// setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING, DRAIN_EXCLUSIVE_ACTIONS)
127-
// ),
128-
// RENDER_ONLY_DEA_STABLE(
129-
// setOf(RENDER_ONLY_WHEN_STATE_CHANGES, DRAIN_EXCLUSIVE_ACTIONS, STABLE_EVENT_HANDLERS)
130-
// ),
125+
RENDER_ONLY_PARTIAL_DEA(
126+
setOf(RENDER_ONLY_WHEN_STATE_CHANGES, PARTIAL_TREE_RENDERING, DRAIN_EXCLUSIVE_ACTIONS)
127+
),
128+
RENDER_ONLY_DEA_STABLE(
129+
setOf(RENDER_ONLY_WHEN_STATE_CHANGES, DRAIN_EXCLUSIVE_ACTIONS, STABLE_EVENT_HANDLERS)
130+
),
131131
RENDER_ONLY_CONFLATE_PARTIAL_STABLE(
132132
setOf(
133133
RENDER_ONLY_WHEN_STATE_CHANGES,
@@ -136,31 +136,31 @@ public enum class RuntimeConfigOptions {
136136
STABLE_EVENT_HANDLERS,
137137
)
138138
),
139-
// RENDER_ONLY_CONFLATE_PARTIAL_DEA(
140-
// setOf(
141-
// RENDER_ONLY_WHEN_STATE_CHANGES,
142-
// CONFLATE_STALE_RENDERINGS,
143-
// PARTIAL_TREE_RENDERING,
144-
// DRAIN_EXCLUSIVE_ACTIONS,
145-
// )
146-
// ),
147-
// RENDER_ONLY_PARTIAL_STABLE_DEA(
148-
// setOf(
149-
// RENDER_ONLY_WHEN_STATE_CHANGES,
150-
// PARTIAL_TREE_RENDERING,
151-
// STABLE_EVENT_HANDLERS,
152-
// DRAIN_EXCLUSIVE_ACTIONS,
153-
// )
154-
// ),
155-
// RENDER_ONLY_CONFLATE_PARTIAL_STABLE_DEA(
156-
// setOf(
157-
// RENDER_ONLY_WHEN_STATE_CHANGES,
158-
// CONFLATE_STALE_RENDERINGS,
159-
// PARTIAL_TREE_RENDERING,
160-
// STABLE_EVENT_HANDLERS,
161-
// DRAIN_EXCLUSIVE_ACTIONS,
162-
// )
163-
// ),
139+
RENDER_ONLY_CONFLATE_PARTIAL_DEA(
140+
setOf(
141+
RENDER_ONLY_WHEN_STATE_CHANGES,
142+
CONFLATE_STALE_RENDERINGS,
143+
PARTIAL_TREE_RENDERING,
144+
DRAIN_EXCLUSIVE_ACTIONS,
145+
)
146+
),
147+
RENDER_ONLY_PARTIAL_STABLE_DEA(
148+
setOf(
149+
RENDER_ONLY_WHEN_STATE_CHANGES,
150+
PARTIAL_TREE_RENDERING,
151+
STABLE_EVENT_HANDLERS,
152+
DRAIN_EXCLUSIVE_ACTIONS,
153+
)
154+
),
155+
RENDER_ONLY_CONFLATE_PARTIAL_STABLE_DEA(
156+
setOf(
157+
RENDER_ONLY_WHEN_STATE_CHANGES,
158+
CONFLATE_STALE_RENDERINGS,
159+
PARTIAL_TREE_RENDERING,
160+
STABLE_EVENT_HANDLERS,
161+
DRAIN_EXCLUSIVE_ACTIONS,
162+
)
163+
),
164164
}
165165
}
166166
}

0 commit comments

Comments
 (0)