square / workflow

A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
https://square.github.io/workflow
Apache License 2.0
1.12k stars 80 forks source link

Discuss: Allow "input" to update for a workflow in a `ContainerViewController`/`WorkflowHost` #351

Closed davidapgar closed 5 years ago

davidapgar commented 5 years ago

When rendering a child workflow, the "input" (ie: the Workflow) is updated each time (allowing it to handle an update to its input, via workflowDidChange).

Currently, the root workflow hosted in a WorkflowHost (and ContainerViewController) does not provide any means to update the Workflow - it is just the root workflow, so the outside doesn't have a path to update the input.

We should consider adding this (I believe the Android version does have support for this)

zach-klippenstein commented 5 years ago

We do, our WorkflowHost takes a ReceiveChannel (Signal) of inputs. Super handy because it also lets the first input be provided asynchronously, which turns out to be a pretty common use case given the way our internal integration works.

Here's the change: https://github.com/square/workflow/pull/282/files#diff-c9e75405c1366dc37bf068c0cd37762c