@@ -10,12 +10,30 @@ 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.state],
17
+ * along with a [setOutput][WorkflowAction.Updater.setOutput] function.
18
+ * The [state][WorkflowAction.Updater.state] can be updated with a new [StateT] instance
19
+ * that will become the current one after the [apply] function finishes.
20
+ *
21
+ * It is possible for one [WorkflowAction] to delegate to another, although the API is a bit opaque:
22
+ *
23
+ * val actionA = action {
24
+ * }
25
+ *
26
+ * val actionB = action {
27
+ * val (newState, outputApplied) = actionA.applyTo(props, state)
28
+ * state = newState
29
+ * outputApplied.output?.value?.let { setOutput(it) }
30
+ * }
13
31
*/
14
32
public abstract class WorkflowAction <in PropsT , StateT , out OutputT > {
15
33
16
34
/* *
17
- * The context for calls to [WorkflowAction.apply]. Allows the action to set the
18
- * [state], and to emit the [ setOutput].
35
+ * The context for calls to [WorkflowAction.apply]. Allows the action to read and change the
36
+ * [state], and to emit an [output][ setOutput] value .
19
37
*
20
38
* @param state the state that the workflow should move to. Default is the current state.
21
39
*/
0 commit comments