File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
workflow-core/src/commonMain/kotlin/com/squareup/workflow1 Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,28 @@ import kotlin.jvm.JvmOverloads
10
10
11
11
/* *
12
12
* An atomic operation that updates the state of a [Workflow], and also optionally emits an output.
13
+ *
14
+ * A [WorkflowAction]'s [apply] method is executed in the context of an [Updater][WorkflowAction.Updater],
15
+ * which provides access to the current [props][WorkflowAction.Updater.props] and
16
+ * [state][WorkflowAction.Updater.props]. The latter can be updated with a new [StateT] instance
17
+ * that will become the current one after the [apply] function finishes.
18
+ *
19
+ * It is possible for one [WorkflowAction] to delegate to another, although the API is a bit opaque:
20
+ *
21
+ * val actionA = action {
22
+ * }
23
+ *
24
+ * val actionB = action {
25
+ * val (newState, outputApplied) = actionA.applyTo(props, state)
26
+ * state = newState
27
+ * outputApplied.output?.value?.let { setOutput(it) }
28
+ * }
13
29
*/
14
30
public abstract class WorkflowAction <in PropsT , StateT , out OutputT > {
15
31
16
32
/* *
17
- * The context for calls to [WorkflowAction.apply]. Allows the action to set the
18
- * [state], and to emit the [ setOutput].
33
+ * The context for calls to [WorkflowAction.apply]. Allows the action to read and change the
34
+ * [state], and to emit an [output][ setOutput] value .
19
35
*
20
36
* @param state the state that the workflow should move to. Default is the current state.
21
37
*/
You can’t perform that action at this time.
0 commit comments