Skip to content

Commit 8b09897

Browse files
Merge pull request #151 from square/zachklipp/restore-output-order
Revert "Emit output before next render pass."
2 parents 56dc076 + 4363566 commit 8b09897

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

workflow-runtime/src/main/java/com/squareup/workflow1/RenderWorkflow.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,12 @@ fun <PropsT, OutputT, RenderingT> renderWorkflowIn(
151151
// It might look weird to start by consuming the output before getting the rendering below,
152152
// but remember the first render pass already occurred above, before this coroutine was even
153153
// launched.
154-
runner.nextOutput()
155-
?.let { onOutput(it.value) }
154+
val output = runner.nextOutput()
156155

156+
// After receiving an output, the next render pass must be done before emitting that output,
157+
// so that the workflow states appear consistent to observers of the outputs and renderings.
157158
renderingsAndSnapshots.value = runner.nextRendering()
159+
output?.let { onOutput(it.value) }
158160
}
159161
}
160162

workflow-runtime/src/test/java/com/squareup/workflow1/RenderWorkflowInTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ class RenderWorkflowInTest {
439439
assertEquals(
440440
listOf(
441441
"rendering({no output})",
442-
"output(output)",
443-
"rendering(output)"
442+
"rendering(output)",
443+
"output(output)"
444444
),
445445
events
446446
)

0 commit comments

Comments
 (0)