Skip to content

Commit b084b16

Browse files
Emit output before next render pass.
Fixes #54.
1 parent 85328f5 commit b084b16

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

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

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

163-
// After receiving an output, the next render pass must be done before emitting that output,
164-
// so that the workflow states appear consistent to observers of the outputs and renderings.
165164
renderingsAndSnapshots.value = runner.nextRendering()
166-
output?.let { onOutput(it.value) }
167165
}
168166
}
169167

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ class RenderWorkflowInTest {
391391
assertEquals(
392392
listOf(
393393
"rendering({no output})",
394-
"rendering(output)",
395-
"output(output)"
394+
"output(output)",
395+
"rendering(output)"
396396
),
397397
events
398398
)

0 commit comments

Comments
 (0)