//workflow/com.squareup.workflow1
Package com.squareup.workflow1¶
Types¶
Name | Summary |
---|---|
BaseRenderContext | [jvm] Content interface BaseRenderContext More info Facilities for a Workflow to interact with other Workflows and the outside world from inside a render function. |
ImpostorWorkflow | [jvm] Content interface ImpostorWorkflow More info Optional interface that Workflows should implement if they need the runtime to consider their identity to include a child workflow’s identity. |
LifecycleWorker | [jvm] Content abstract class LifecycleWorker : Worker<Nothing> More info Worker that performs some action when the worker is started and/or stopped. |
NoopWorkflowInterceptor | [jvm] Content object NoopWorkflowInterceptor : WorkflowInterceptor More info A WorkflowInterceptor that does not intercept anything. |
RenderingAndSnapshot | [jvm] Content class RenderingAndSnapshot More info Tuple of rendering and snapshot used by renderWorkflowIn. |
SimpleLoggingWorkflowInterceptor | [jvm] Content open class SimpleLoggingWorkflowInterceptor : WorkflowInterceptor More info A WorkflowInterceptor that just prints all method calls using log. |
Sink | [jvm] Content fun fun interface Sink More info An object that receives values (commonly events or WorkflowAction). |
Snapshot | [jvm] Content class Snapshot More info A lazy wrapper of ByteString. |
StatefulWorkflow | [jvm] Content abstract class StatefulWorkflow More info A composable, stateful object that can handle events, delegate to children, subscribe to arbitrary asynchronous events from the outside world, and be saved to a serialized form to be restored later. |
StatelessWorkflow | [jvm] Content abstract class StatelessWorkflow More info Minimal implementation of Workflow that maintains no state of its own. |
TreeSnapshot | [jvm] Content class TreeSnapshot More info Aggregate of all the snapshots of a tree of workflows. |
Worker | [jvm] Content interface Worker More info Represents a unit of asynchronous work that can have zero, one, or multiple outputs. |
Workflow | [jvm] Content interface Workflow More info A composable, optionally-stateful object that can handle events, delegate to children, subscribe to arbitrary asynchronous events from the outside world. |
WorkflowAction | [jvm] Content abstract class WorkflowAction More info An atomic operation that updates the state of a Workflow, and also optionally emits an output. |
WorkflowIdentifier | [jvm] Content class WorkflowIdentifier More info Represents a Workflow‘s “identity” and is used by the runtime to determine whether a workflow is the same as one that was rendered in a previous render pass, in which case its state should be re-used; or if it’s a new workflow and needs to be started. |
WorkflowInterceptor | [jvm] Content interface WorkflowInterceptor More info Provides hooks into the workflow runtime that can be used to instrument or modify the behavior of workflows. |
WorkflowOutput | [jvm] Content class WorkflowOutput More info Wrapper around a potentially-nullable OutputT value. |
Functions¶
Name | Summary |
---|---|
action | [jvm] Content fun <PropsT, StateT, OutputT> action(name: () -> String, apply: WorkflowAction.Updater<PropsT, StateT, OutputT>.() -> Unit): WorkflowAction<PropsT, StateT, OutputT> fun <PropsT, StateT, OutputT> action(name: String = “”, apply: WorkflowAction.Updater<PropsT, StateT, OutputT>.() -> Unit): WorkflowAction<PropsT, StateT, OutputT> More info Creates a WorkflowAction from the apply lambda. [jvm] Content fun <PropsT, StateT, OutputT, RenderingT> StatefulWorkflow<PropsT, StateT, OutputT, RenderingT>.action(name: () -> String, update: WorkflowAction.Updater<PropsT, StateT, OutputT>.() -> Unit): WorkflowAction<PropsT, StateT, OutputT> fun <PropsT, StateT, OutputT, RenderingT> StatefulWorkflow<PropsT, StateT, OutputT, RenderingT>.action(name: String = “”, update: WorkflowAction.Updater<PropsT, StateT, OutputT>.() -> Unit): WorkflowAction<PropsT, StateT, OutputT> fun <PropsT, OutputT, RenderingT> StatelessWorkflow<PropsT, OutputT, RenderingT>.action(name: () -> String, update: WorkflowAction.Updater<PropsT, *, OutputT>.() -> Unit): WorkflowAction<PropsT, Nothing, OutputT> fun <PropsT, OutputT, RenderingT> StatelessWorkflow<PropsT, OutputT, RenderingT>.action(name: String = “”, update: WorkflowAction.Updater<PropsT, *, OutputT>.() -> Unit): WorkflowAction<PropsT, Nothing, OutputT> More info Convenience to create a WorkflowAction with parameter types matching those of the receiving StatefulWorkflow. |
applyTo | [jvm] Content fun <PropsT, StateT, OutputT> WorkflowAction<PropsT, StateT, OutputT>.applyTo(props: PropsT, state: StateT): Pair<StateT, WorkflowOutput<OutputT>?> More info Applies this WorkflowAction to state. |
asWorker | [jvm] Content inline fun <OutputT> Flow<OutputT>.asWorker(): Worker<OutputT> More info Returns a Worker that will, when performed, emit whatever this Flow receives. |
contraMap | [jvm] Content fun <T1, T2> Sink<T1>.contraMap(transform: (T2) -> T1): Sink<T2> More info Generates a new sink of type T2. |
mapRendering | [jvm] Content fun <PropsT, OutputT, FromRenderingT, ToRenderingT> Workflow<PropsT, OutputT, FromRenderingT>.mapRendering(transform: (FromRenderingT) -> ToRenderingT): Workflow<PropsT, OutputT, ToRenderingT> More info Uses the given function to transform a Workflow that renders FromRenderingT to one renders ToRenderingT, |
parse | [jvm] Content inline fun <T> ByteString.parse(block: (BufferedSource) -> T): T More info Runs block with a BufferedSource that will read from this ByteString. |
readBooleanFromInt | [jvm] Content fun BufferedSource.readBooleanFromInt(): Boolean |
readByteStringWithLength | [jvm] Content fun BufferedSource.readByteStringWithLength(): ByteString |
readEnumByOrdinal | [jvm] Content inline fun <T : Enum<T>> BufferedSource.readEnumByOrdinal(): T |
readFloat | [jvm] Content fun BufferedSource.readFloat(): Float |
readList | [jvm] Content inline fun <T> BufferedSource.readList(reader: BufferedSource.() -> T): List<T> |
readNullable | [jvm] Content fun <T : Any> BufferedSource.readNullable(reader: BufferedSource.() -> T): T? |
readOptionalEnumByOrdinal | [jvm] Content inline fun <T : Enum<T>> BufferedSource.readOptionalEnumByOrdinal(): T? |
readOptionalUtf8WithLength | [jvm] Content fun BufferedSource.readOptionalUtf8WithLength(): String? |
readUtf8WithLength | [jvm] Content fun BufferedSource.readUtf8WithLength(): String |
renderChild | [jvm] Content fun <PropsT, StateT, OutputT, ChildRenderingT> BaseRenderContext<PropsT, StateT, OutputT>.renderChild(child: Workflow<Unit, Nothing, ChildRenderingT>, key: String = “”): ChildRenderingT More info Convenience alias of BaseRenderContext.renderChild for children that don’t take props or emit output. [jvm] Content fun <PropsT, ChildPropsT, StateT, OutputT, ChildRenderingT> BaseRenderContext<PropsT, StateT, OutputT>.renderChild(child: Workflow<ChildPropsT, Nothing, ChildRenderingT>, props: ChildPropsT, key: String = “”): ChildRenderingT More info Convenience alias of BaseRenderContext.renderChild for workflows that don’t emit output. [jvm] Content fun <PropsT, StateT, OutputT, ChildOutputT, ChildRenderingT> BaseRenderContext<PropsT, StateT, OutputT>.renderChild(child: Workflow<Unit, ChildOutputT, ChildRenderingT>, key: String = “”, handler: (ChildOutputT) -> WorkflowAction<PropsT, StateT, OutputT>): ChildRenderingT More info Convenience alias of BaseRenderContext.renderChild for workflows that don’t take props. |
RenderContext | [jvm] Content fun <PropsT, OutputT, RenderingT> RenderContext(baseContext: BaseRenderContext<PropsT, *, OutputT>, workflow: StatelessWorkflow<PropsT, OutputT, RenderingT>): StatelessWorkflow.RenderContext<PropsT, OutputT, RenderingT> More info Creates a RenderContext from a BaseRenderContext for the given StatelessWorkflow. [jvm] Content fun <PropsT, StateT, OutputT, RenderingT> RenderContext(baseContext: BaseRenderContext<PropsT, StateT, OutputT>, workflow: StatefulWorkflow<PropsT, StateT, OutputT, RenderingT>): StatefulWorkflow.RenderContext<PropsT, StateT, OutputT, RenderingT> More info Creates a RenderContext from a BaseRenderContext for the given StatefulWorkflow. |
rendering | [jvm] Content fun <RenderingT> Workflow.Companion.rendering(rendering: RenderingT): Workflow<Unit, Nothing, RenderingT> More info Returns a workflow that does nothing but echo the given rendering. |
renderWorkflowIn | [jvm] Content fun <PropsT, OutputT, RenderingT> renderWorkflowIn(workflow: Workflow<PropsT, OutputT, RenderingT>, scope: CoroutineScope, props: StateFlow<PropsT>, initialSnapshot: TreeSnapshot? = null, interceptors: List<WorkflowInterceptor> = emptyList(), onOutput: suspend (OutputT) -> Unit): StateFlow<RenderingAndSnapshot<RenderingT>> More info Launches the workflow in a new coroutine in scope and returns a StateFlow of its renderings and snapshots. |
runningWorker | [jvm] Content inline fun <W : Worker<Nothing>, PropsT, StateT, OutputT> BaseRenderContext<PropsT, StateT, OutputT>.runningWorker(worker: W, key: String = “”) More info Ensures a Worker that never emits anything is running. [jvm] Content inline fun <T, W : Worker<T>, PropsT, StateT, OutputT> BaseRenderContext<PropsT, StateT, OutputT>.runningWorker(worker: W, key: String = “”, noinline handler: (T) -> WorkflowAction<PropsT, StateT, OutputT>) More info Ensures worker is running. |
stateful | [jvm] Content inline fun <StateT, OutputT, RenderingT> Workflow.Companion.stateful(initialState: StateT, crossinline render: BaseRenderContext<Unit, StateT, OutputT>.(StateT) -> RenderingT): StatefulWorkflow<Unit, StateT, OutputT, RenderingT> More info Returns a stateful Workflow, with no props, implemented via the given function. [jvm] Content inline fun <PropsT, StateT, OutputT, RenderingT> Workflow.Companion.stateful(crossinline initialState: (PropsT) -> StateT, crossinline render: BaseRenderContext<PropsT, StateT, OutputT>.(PropsT, StateT) -> RenderingT, crossinline onPropsChanged: (PropsT, PropsT, StateT) -> StateT = { _, _, state -> state }): StatefulWorkflow<PropsT, StateT, OutputT, RenderingT> inline fun <PropsT, StateT, OutputT, RenderingT> Workflow.Companion.stateful(crossinline initialState: (PropsT, Snapshot?) -> StateT, crossinline render: BaseRenderContext<PropsT, StateT, OutputT>.(PropsT, StateT) -> RenderingT, crossinline snapshot: (StateT) -> Snapshot?, crossinline onPropsChanged: (PropsT, PropsT, StateT) -> StateT = { _, _, state -> state }): StatefulWorkflow<PropsT, StateT, OutputT, RenderingT> More info Returns a stateful Workflow implemented via the given functions. [jvm] Content inline fun <StateT, OutputT, RenderingT> Workflow.Companion.stateful(crossinline initialState: (Snapshot?) -> StateT, crossinline render: BaseRenderContext<Unit, StateT, OutputT>.(StateT) -> RenderingT, crossinline snapshot: (StateT) -> Snapshot?): StatefulWorkflow<Unit, StateT, OutputT, RenderingT> More info Returns a stateful Workflow, with no props, implemented via the given functions. |
stateless | [jvm] Content inline fun <PropsT, OutputT, RenderingT> Workflow.Companion.stateless(crossinline render: BaseRenderContext<PropsT, Nothing, OutputT>.(PropsT) -> RenderingT): Workflow<PropsT, OutputT, RenderingT> More info Returns a stateless Workflow via the given render function. |
transform | [jvm] Content fun <T, R> Worker<T>.transform(transform: (Flow<T>) -> Flow<R>): Worker<R> More info Returns a Worker that transforms this Worker‘s Flow by calling transform. |
unsnapshottableIdentifier | [jvm] Content fun unsnapshottableIdentifier(type: KType): WorkflowIdentifier More info Creates a WorkflowIdentifier that is not capable of being snapshotted and will cause any ImpostorWorkflow workflow identified by it to also not be snapshotted. |
writeBooleanAsInt | [jvm] Content fun BufferedSink.writeBooleanAsInt(bool: Boolean): BufferedSink |
writeByteStringWithLength | [jvm] Content fun BufferedSink.writeByteStringWithLength(bytes: ByteString): BufferedSink |
writeEnumByOrdinal | [jvm] Content fun <T : Enum<T>> BufferedSink.writeEnumByOrdinal(enumVal: T): BufferedSink |
writeFloat | [jvm] Content fun BufferedSink.writeFloat(float: Float): BufferedSink |
writeList | [jvm] Content inline fun <T> BufferedSink.writeList(values: List<T>, writer: BufferedSink.(T) -> Unit): BufferedSink |
writeNullable | [jvm] Content fun <T : Any> BufferedSink.writeNullable(obj: T?, writer: BufferedSink.(T) -> Unit): BufferedSink |
writeOptionalEnumByOrdinal | [jvm] Content fun <T : Enum<T>> BufferedSink.writeOptionalEnumByOrdinal(enumVal: T?): BufferedSink |
writeOptionalUtf8WithLength | [jvm] Content fun BufferedSink.writeOptionalUtf8WithLength(str: String?): BufferedSink |
writeUtf8WithLength | [jvm] Content fun BufferedSink.writeUtf8WithLength(str: String): BufferedSink |
Properties¶
Name | Summary |
---|---|
identifier | [jvm] val Workflow<*, *, *>.identifier: WorkflowIdentifierThe WorkflowIdentifier that identifies this Workflow. |
workflowIdentifier | [jvm] val KClass<out Workflow<*, *, *>>.workflowIdentifier: WorkflowIdentifierThe WorkflowIdentifier that identifies the workflow this KClass represents. |