Skip to content

Commit b198b58

Browse files
Emit output before next render pass.
Fixes #54.
1 parent f441c32 commit b198b58

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,5 +363,9 @@ class RenderWorkflowInTest {
363363
assertFalse(scope.isActive)
364364
}
365365

366+
@Test fun `output is emitted before next render pass`() {
367+
TODO()
368+
}
369+
366370
private class ExpectedException : RuntimeException()
367371
}

0 commit comments

Comments
 (0)