Skip to content

//workflow/com.squareup.workflow1/BaseRenderContext/runningSideEffect

runningSideEffect

[jvm]
Content
abstract fun runningSideEffect(key: String, sideEffect: suspend CoroutineScope.() -> Unit)
More info

Ensures sideEffect is running with the given key.

The first render pass in which this method is called, sideEffect will be launched in a new coroutine that will be scoped to the rendering Workflow. Subsequent render passes that invoke this method with the same key will not launch the coroutine again, but let it keep running. Note that if a different function is passed with the same key, the side effect will not be restarted, the new function will simply be ignored. The next render pass in which the workflow does not call this method with the same key, the coroutine running sideEffect will be cancelled.

The coroutine will run with the same CoroutineContext that the workflow runtime is running in. The side effect coroutine will not be started until after the first render call than runs it returns.

Parameters

jvm

key

The string key that is used to distinguish between side effects.

sideEffect

The suspend function that will be launched in a coroutine to perform the side effect.