Skip to content

//workflow/com.squareup.workflow1/runningWorker

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. Since worker can’t emit anything, it can’t trigger any WorkflowActions.

If your Worker does not output anything, then simply use runningSideEffect.

Parameters

jvm

key

An optional string key that is used to distinguish between identical Workers.

[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. When the Worker emits an output, handler is called to determine the WorkflowAction to take. When the worker finishes, nothing happens (although another render pass may be triggered).

Like workflows, workers are kept alive across multiple render passes if they’re the same type, and different workers of distinct types can be run concurrently. However, unlike workflows, workers are compared by their declared type, not their actual type. This means that if you pass a worker stored in a variable to this function, the type that will be used to compare the worker will be the type of the variable, not the type of the object the variable refers to.

Parameters

jvm

key

An optional string key that is used to distinguish between identical Workers.