Skip to content

Commit 2b77964

Browse files
Add CoroutineScope to initialState; SessionWorkflow to aid rollout
Adds 'Lifecycle' related tests to prove out SessionWorkflow's ability to effectively track lifecycle in the failing scenario. Adds comments describing the failing scenario of issue 1093, and how this can workaround it to fix it. Also address 990 which has been separately requested. Closes 990 Closes 1093
1 parent c879b40 commit 2b77964

File tree

21 files changed

+600
-38
lines changed

21 files changed

+600
-38
lines changed

workflow-core/api/workflow-core.api

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@ public final class com/squareup/workflow1/PropsUpdated : com/squareup/workflow1/
9191
public static final field INSTANCE Lcom/squareup/workflow1/PropsUpdated;
9292
}
9393

94+
public abstract class com/squareup/workflow1/SessionWorkflow : com/squareup/workflow1/StatefulWorkflow {
95+
public fun <init> ()V
96+
public final fun initialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;)Ljava/lang/Object;
97+
public abstract fun initialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlinx/coroutines/CoroutineScope;)Ljava/lang/Object;
98+
}
99+
100+
public final class com/squareup/workflow1/SessionWorkflowKt {
101+
public static final fun sessionWorkflow (Lcom/squareup/workflow1/Workflow$Companion;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lcom/squareup/workflow1/SessionWorkflow;
102+
public static final fun sessionWorkflow (Lcom/squareup/workflow1/Workflow$Companion;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lcom/squareup/workflow1/SessionWorkflow;
103+
public static final fun sessionWorkflow (Lcom/squareup/workflow1/Workflow$Companion;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;)Lcom/squareup/workflow1/SessionWorkflow;
104+
public static final fun sessionWorkflow (Lcom/squareup/workflow1/Workflow$Companion;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Lcom/squareup/workflow1/SessionWorkflow;
105+
public static synthetic fun sessionWorkflow$default (Lcom/squareup/workflow1/Workflow$Companion;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/squareup/workflow1/SessionWorkflow;
106+
public static synthetic fun sessionWorkflow$default (Lcom/squareup/workflow1/Workflow$Companion;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/squareup/workflow1/SessionWorkflow;
107+
}
108+
94109
public abstract interface class com/squareup/workflow1/Sink {
95110
public abstract fun send (Ljava/lang/Object;)V
96111
}
@@ -142,6 +157,7 @@ public abstract class com/squareup/workflow1/StatefulWorkflow : com/squareup/wor
142157
public final fun asStatefulWorkflow ()Lcom/squareup/workflow1/StatefulWorkflow;
143158
public fun getCachedIdentifier ()Lcom/squareup/workflow1/WorkflowIdentifier;
144159
public abstract fun initialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;)Ljava/lang/Object;
160+
public fun initialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlinx/coroutines/CoroutineScope;)Ljava/lang/Object;
145161
public fun onPropsChanged (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
146162
public abstract fun render (Ljava/lang/Object;Ljava/lang/Object;Lcom/squareup/workflow1/StatefulWorkflow$RenderContext;)Ljava/lang/Object;
147163
public fun setCachedIdentifier (Lcom/squareup/workflow1/WorkflowIdentifier;)V
@@ -240,6 +256,9 @@ public final class com/squareup/workflow1/WorkflowAction$Updater {
240256
public final fun setState (Ljava/lang/Object;)V
241257
}
242258

259+
public abstract interface annotation class com/squareup/workflow1/WorkflowExperimentalApi : java/lang/annotation/Annotation {
260+
}
261+
243262
public final class com/squareup/workflow1/WorkflowIdentifier {
244263
public static final field Companion Lcom/squareup/workflow1/WorkflowIdentifier$Companion;
245264
public fun equals (Ljava/lang/Object;)Z

workflow-core/src/commonMain/kotlin/com/squareup/workflow1/BaseRenderContext.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ public interface BaseRenderContext<out PropsT, StateT, in OutputT> {
9595
* that the workflow runtime is running in. The side effect coroutine will not be started until
9696
* _after_ the first render call than runs it returns.
9797
*
98+
* Note that there is currently an [issue](https://github.com/square/workflow-kotlin/issues/1093)
99+
* when a [runningSideEffect] (and thus also [runningWorker], or the parent Workflow of either
100+
* via [renderChild]) is declared as running (or rendering) in one render pass and
101+
* then not declared in the next render pass and both those consecutive render passes happen
102+
* synchronously - i.e. without the [CoroutineDispatcher][kotlinx.coroutines.CoroutineDispatcher]
103+
* for the Workflow runtime being able to dispatch asynchronously. This is because the jobs for
104+
* side effects are launched lazily in order to ensure they happen after the render pass, but if
105+
* the [CoroutineScope]'s job (the parent for all these jobs) is cancelled before these lazy
106+
* coroutines have a chance to dispatch, then they will never run at all. For more details, and
107+
* to report problems with this, see the [issue](https://github.com/square/workflow-kotlin/issues/1093).
108+
* If you need guaranteed execution for some code in this scenario (like for cleanup), please
109+
* use a [SessionWorkflow] and the [SessionWorkflow.initialState] that provides the
110+
* [CoroutineScope] which is equivalent to the lifetime of the Workflow node in the tree. The
111+
* [Job][kotlinx.coroutines.Job] can be extracted from that and used to get guaranteed to be
112+
* executed lifecycle hooks.
113+
*
98114
* @param key The string key that is used to distinguish between side effects.
99115
* @param sideEffect The suspend function that will be launched in a coroutine to perform the
100116
* side effect.
@@ -281,6 +297,9 @@ public inline fun <reified W : Worker<Nothing>, PropsT, StateT, OutputT>
281297
* pass a worker stored in a variable to this function, the type that will be used to compare the
282298
* worker will be the type of the variable, not the type of the object the variable refers to.
283299
*
300+
* Note that there is currently an [issue](https://github.com/square/workflow-kotlin/issues/1093)
301+
* which can effect [runningWorker]. See more details at [BaseRenderContext.runningSideEffect].
302+
*
284303
* @param key An optional string key that is used to distinguish between identical [Worker]s.
285304
*/
286305
public inline fun <T, reified W : Worker<T>, PropsT, StateT, OutputT>

workflow-core/src/commonMain/kotlin/com/squareup/workflow1/LifecycleWorker.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import kotlin.jvm.JvmName
1414
*
1515
* A [Worker] is stopped when its parent [Workflow] finishes a render pass without running the
1616
* worker, or when the parent workflow is itself torn down.
17+
*
18+
* Note that there is currently an [issue](https://github.com/square/workflow-kotlin/issues/1093)
19+
* which can effect a [LifecycleWorker]. See more details at [BaseRenderContext.runningSideEffect].
1720
*/
1821
public abstract class LifecycleWorker : Worker<Nothing> {
1922

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
package com.squareup.workflow1
2+
3+
import kotlinx.coroutines.CoroutineScope
4+
5+
/**
6+
* @see [StatefulWorkflow] for the main description of this class.
7+
*
8+
* This is an extension of the API that allows for [initialState] to also receive a [CoroutineScope]
9+
* that corresponds with the lifetime of this Workflow. In other words, the [CoroutineScope] is
10+
* created when an session of this Workflow is active. A session is active from the first time one
11+
* node of it is rendered, until it is no longer rendered.
12+
*
13+
* This API extension exists on [StatefulWorkflow] as well, but it is confusing because the version
14+
* of [initialState] that does not have the [CoroutineScope] must also be implemented as it is
15+
* an abstract fun, even though it would never be used.
16+
* With this version, that confusion is removed and only the version of [initialState] with the
17+
* [CoroutineScope] must be implemented.
18+
*/
19+
@WorkflowExperimentalApi
20+
public abstract class SessionWorkflow<
21+
in PropsT,
22+
StateT,
23+
out OutputT,
24+
out RenderingT
25+
> : StatefulWorkflow<PropsT, StateT, OutputT, RenderingT>() {
26+
27+
/**
28+
* @see [StatefulWorkflow.initialState] for kdoc on the base function of this method.
29+
*
30+
* This version adds the following:
31+
* @param workflowScope A [CoroutineScope] that has been created when this Workflow is first
32+
* rendered and canceled when it is no longer rendered.
33+
*
34+
* This [CoroutineScope] be used to own the transforms on, e.g. a [StateFlow][kotlinx.coroutines.flow.StateFlow],
35+
* in order to link them to the lifetime of this Workflow's session - from first rendering until
36+
* no longer rendered. e.g.,
37+
* ```
38+
* val transformedStateFlow = myStateFlow1.combine(myStateFlow2).
39+
* stateIn(workflowScope, SharingStarted.Eagerly, myStateFlow1.value + myStateFlow2.value)
40+
* ```
41+
*
42+
* **Note Carefully**: Neither [workflowScope] nor any of these transformed/computed dependencies
43+
* should be stored by this Workflow instance. This could be re-created, or re-used unexpectedly
44+
* and should not have its own state. Instead, the transformed/computed dependencies must be
45+
* put into the [StateT] of this Workflow in order to be properly maintained.
46+
*/
47+
public abstract override fun initialState(
48+
props: PropsT,
49+
snapshot: Snapshot?,
50+
workflowScope: CoroutineScope
51+
): StateT
52+
53+
/**
54+
* Do not use this in favor of the version of [initialState] above that includes the Workflow's
55+
* [CoroutineScope]
56+
*/
57+
public final override fun initialState(
58+
props: PropsT,
59+
snapshot: Snapshot?
60+
): StateT {
61+
error("SessionWorkflow should never call initialState without the CoroutineScope.")
62+
}
63+
}
64+
65+
/**
66+
* Returns a [SessionWorkflow] implemented via the given functions.
67+
*/
68+
@WorkflowExperimentalApi
69+
public inline fun <PropsT, StateT, OutputT, RenderingT> Workflow.Companion.sessionWorkflow(
70+
crossinline initialState: (PropsT, Snapshot?, CoroutineScope) -> StateT,
71+
crossinline render: BaseRenderContext<PropsT, StateT, OutputT>.(
72+
props: PropsT,
73+
state: StateT
74+
) -> RenderingT,
75+
crossinline snapshot: (StateT) -> Snapshot?,
76+
crossinline onPropsChanged: (
77+
old: PropsT,
78+
new: PropsT,
79+
state: StateT
80+
) -> StateT = { _, _, state -> state }
81+
): SessionWorkflow<PropsT, StateT, OutputT, RenderingT> =
82+
object : SessionWorkflow<PropsT, StateT, OutputT, RenderingT>() {
83+
override fun initialState(
84+
props: PropsT,
85+
snapshot: Snapshot?,
86+
workflowScope: CoroutineScope
87+
): StateT = initialState(props, snapshot, workflowScope)
88+
89+
override fun onPropsChanged(
90+
old: PropsT,
91+
new: PropsT,
92+
state: StateT
93+
): StateT = onPropsChanged(old, new, state)
94+
95+
override fun render(
96+
renderProps: PropsT,
97+
renderState: StateT,
98+
context: RenderContext
99+
): RenderingT = render(context, renderProps, renderState)
100+
101+
override fun snapshotState(state: StateT) = snapshot(state)
102+
}
103+
104+
/**
105+
* Returns a [SessionWorkflow], with no props, implemented via the given functions.
106+
*/
107+
@WorkflowExperimentalApi
108+
public inline fun <StateT, OutputT, RenderingT> Workflow.Companion.sessionWorkflow(
109+
crossinline initialState: (Snapshot?, CoroutineScope) -> StateT,
110+
crossinline render: BaseRenderContext<Unit, StateT, OutputT>.(state: StateT) -> RenderingT,
111+
crossinline snapshot: (StateT) -> Snapshot?
112+
): SessionWorkflow<Unit, StateT, OutputT, RenderingT> = sessionWorkflow(
113+
{ _, initialSnapshot, workflowScope -> initialState(initialSnapshot, workflowScope) },
114+
{ _, state -> render(state) },
115+
snapshot
116+
)
117+
118+
/**
119+
* Returns a [SessionWorkflow] implemented via the given functions.
120+
*
121+
* This overload does not support snapshotting, but there are other overloads that do.
122+
*/
123+
@WorkflowExperimentalApi
124+
public inline fun <PropsT, StateT, OutputT, RenderingT> Workflow.Companion.sessionWorkflow(
125+
crossinline initialState: (PropsT, CoroutineScope) -> StateT,
126+
crossinline render: BaseRenderContext<PropsT, StateT, OutputT>.(
127+
props: PropsT,
128+
state: StateT
129+
) -> RenderingT,
130+
crossinline onPropsChanged: (
131+
old: PropsT,
132+
new: PropsT,
133+
state: StateT
134+
) -> StateT = { _, _, state -> state }
135+
): SessionWorkflow<PropsT, StateT, OutputT, RenderingT> = sessionWorkflow(
136+
{ props, _, workflowScope -> initialState(props, workflowScope) },
137+
render,
138+
{ null },
139+
onPropsChanged
140+
)
141+
142+
/**
143+
* Returns a [SessionWorkflow], with no props, implemented via the given function.
144+
*
145+
* This overload does not support snapshots, but there are others that do.
146+
*/
147+
@WorkflowExperimentalApi
148+
public inline fun <StateT, OutputT, RenderingT> Workflow.Companion.sessionWorkflow(
149+
crossinline initialState: (CoroutineScope) -> StateT,
150+
crossinline render: BaseRenderContext<Unit, StateT, OutputT>.(state: StateT) -> RenderingT
151+
): SessionWorkflow<Unit, StateT, OutputT, RenderingT> = sessionWorkflow(
152+
{ _, workflowScope -> initialState(workflowScope) },
153+
{ _, state -> render(state) }
154+
)

workflow-core/src/commonMain/kotlin/com/squareup/workflow1/StatefulWorkflow.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
@file:Suppress("DEPRECATION")
21
@file:JvmMultifileClass
32
@file:JvmName("Workflows")
43

54
package com.squareup.workflow1
65

76
import com.squareup.workflow1.StatefulWorkflow.RenderContext
87
import com.squareup.workflow1.WorkflowAction.Companion.toString
9-
import kotlin.LazyThreadSafetyMode.NONE
8+
import kotlinx.coroutines.CoroutineScope
109
import kotlin.jvm.JvmMultifileClass
1110
import kotlin.jvm.JvmName
1211

@@ -93,6 +92,18 @@ public abstract class StatefulWorkflow<
9392
snapshot: Snapshot?
9493
): StateT
9594

95+
/**
96+
* @see [SessionWorkflow.initialState].
97+
* This method should only be used with a [SessionWorkflow]. It's just a pass through here so
98+
* that we can add this behavior for [SessionWorkflow] without disrupting all [StatefulWorkflow]s.
99+
*/
100+
@WorkflowExperimentalApi
101+
public open fun initialState(
102+
props: PropsT,
103+
snapshot: Snapshot?,
104+
workflowScope: CoroutineScope
105+
): StateT = initialState(props, snapshot)
106+
96107
/**
97108
* Called from [RenderContext.renderChild] instead of [initialState] when the workflow is already
98109
* running. This allows the workflow to detect changes in props, and possibly change its state in
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.squareup.workflow1
2+
3+
import kotlin.RequiresOptIn.Level.ERROR
4+
import kotlin.annotation.AnnotationRetention.BINARY
5+
6+
/**
7+
* This is used to mark new core Workflow API that is still considered experimental.
8+
*/
9+
@Target(
10+
AnnotationTarget.CLASS,
11+
AnnotationTarget.PROPERTY,
12+
AnnotationTarget.FUNCTION,
13+
AnnotationTarget.TYPEALIAS
14+
)
15+
@MustBeDocumented
16+
@Retention(value = BINARY)
17+
@RequiresOptIn(level = ERROR)
18+
public annotation class WorkflowExperimentalApi

workflow-runtime/api/workflow-runtime.api

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
public final class com/squareup/workflow1/NoopWorkflowInterceptor : com/squareup/workflow1/WorkflowInterceptor {
22
public static final field INSTANCE Lcom/squareup/workflow1/NoopWorkflowInterceptor;
3-
public fun onInitialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlin/jvm/functions/Function2;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
3+
public fun onInitialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
44
public fun onPropsChanged (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
55
public fun onRender (Ljava/lang/Object;Ljava/lang/Object;Lcom/squareup/workflow1/BaseRenderContext;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
66
public fun onRenderAndSnapshot (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Lcom/squareup/workflow1/RenderingAndSnapshot;
@@ -41,7 +41,7 @@ public class com/squareup/workflow1/SimpleLoggingWorkflowInterceptor : com/squar
4141
protected fun logAfterMethod (Ljava/lang/String;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;[Lkotlin/Pair;)V
4242
protected fun logBeforeMethod (Ljava/lang/String;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;[Lkotlin/Pair;)V
4343
protected fun logError (Ljava/lang/String;)V
44-
public fun onInitialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlin/jvm/functions/Function2;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
44+
public fun onInitialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
4545
public fun onPropsChanged (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
4646
public fun onRender (Ljava/lang/Object;Ljava/lang/Object;Lcom/squareup/workflow1/BaseRenderContext;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
4747
public fun onRenderAndSnapshot (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Lcom/squareup/workflow1/RenderingAndSnapshot;
@@ -66,7 +66,7 @@ public abstract interface annotation class com/squareup/workflow1/WorkflowExperi
6666
}
6767

6868
public abstract interface class com/squareup/workflow1/WorkflowInterceptor {
69-
public abstract fun onInitialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlin/jvm/functions/Function2;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
69+
public abstract fun onInitialState (Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
7070
public abstract fun onPropsChanged (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
7171
public abstract fun onRender (Ljava/lang/Object;Ljava/lang/Object;Lcom/squareup/workflow1/BaseRenderContext;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
7272
public abstract fun onRenderAndSnapshot (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Lcom/squareup/workflow1/RenderingAndSnapshot;
@@ -76,7 +76,7 @@ public abstract interface class com/squareup/workflow1/WorkflowInterceptor {
7676
}
7777

7878
public final class com/squareup/workflow1/WorkflowInterceptor$DefaultImpls {
79-
public static fun onInitialState (Lcom/squareup/workflow1/WorkflowInterceptor;Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlin/jvm/functions/Function2;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
79+
public static fun onInitialState (Lcom/squareup/workflow1/WorkflowInterceptor;Ljava/lang/Object;Lcom/squareup/workflow1/Snapshot;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
8080
public static fun onPropsChanged (Lcom/squareup/workflow1/WorkflowInterceptor;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
8181
public static fun onRender (Lcom/squareup/workflow1/WorkflowInterceptor;Ljava/lang/Object;Ljava/lang/Object;Lcom/squareup/workflow1/BaseRenderContext;Lkotlin/jvm/functions/Function3;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Ljava/lang/Object;
8282
public static fun onRenderAndSnapshot (Lcom/squareup/workflow1/WorkflowInterceptor;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lcom/squareup/workflow1/WorkflowInterceptor$WorkflowSession;)Lcom/squareup/workflow1/RenderingAndSnapshot;

workflow-runtime/src/commonMain/kotlin/com/squareup/workflow1/SimpleLoggingWorkflowInterceptor.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ public open class SimpleLoggingWorkflowInterceptor : WorkflowInterceptor {
2222
override fun <P, S> onInitialState(
2323
props: P,
2424
snapshot: Snapshot?,
25-
proceed: (P, Snapshot?) -> S,
25+
workflowScope: CoroutineScope,
26+
proceed: (P, Snapshot?, CoroutineScope) -> S,
2627
session: WorkflowSession
2728
): S = logMethod("onInitialState", session) {
28-
proceed(props, snapshot)
29+
proceed(props, snapshot, workflowScope)
2930
}
3031

3132
override fun <P, S> onPropsChanged(

0 commit comments

Comments
 (0)