Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how WorkflowAction can delegate #1156

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,28 @@ import kotlin.jvm.JvmOverloads

/**
* An atomic operation that updates the state of a [Workflow], and also optionally emits an output.
*
* A [WorkflowAction]'s [apply] method is executed in the context of an [Updater][WorkflowAction.Updater],
* which provides access to the current [props][WorkflowAction.Updater.props] and
* [state][WorkflowAction.Updater.props]. The latter can be updated with a new [StateT] instance
* that will become the current one after the [apply] function finishes.
rjrjr marked this conversation as resolved.
Show resolved Hide resolved
*
* It is possible for one [WorkflowAction] to delegate to another, although the API is a bit opaque:
*
* val actionA = action {
* }
*
* val actionB = action {
* val (newState, outputApplied) = actionA.applyTo(props, state)
* state = newState
* outputApplied.output?.value?.let { setOutput(it) }
* }
*/
public abstract class WorkflowAction<in PropsT, StateT, out OutputT> {

/**
* The context for calls to [WorkflowAction.apply]. Allows the action to set the
* [state], and to emit the [setOutput].
* The context for calls to [WorkflowAction.apply]. Allows the action to read and change the
* [state], and to emit an [output][setOutput] value.
*
* @param state the state that the workflow should move to. Default is the current state.
*/
Expand Down
Loading