@@ -2,15 +2,19 @@ package com.squareup.workflow1.internal.compose
2
2
3
3
import androidx.compose.runtime.Composable
4
4
import androidx.compose.runtime.DisposableEffect
5
+ import androidx.compose.runtime.NonRestartableComposable
6
+ import androidx.compose.runtime.ReadOnlyComposable
5
7
import androidx.compose.runtime.collection.MutableVector
6
8
import androidx.compose.runtime.currentRecomposeScope
7
9
import androidx.compose.runtime.getValue
8
10
import androidx.compose.runtime.key
11
+ import androidx.compose.runtime.mutableStateOf
9
12
import androidx.compose.runtime.remember
10
13
import androidx.compose.runtime.rememberCoroutineScope
11
14
import androidx.compose.runtime.rememberUpdatedState
12
15
import androidx.compose.runtime.saveable.LocalSaveableStateRegistry
13
16
import androidx.compose.runtime.saveable.SaveableStateRegistry
17
+ import androidx.compose.runtime.setValue
14
18
import com.squareup.workflow1.ActionApplied
15
19
import com.squareup.workflow1.ActionProcessingResult
16
20
import com.squareup.workflow1.NoopWorkflowInterceptor
@@ -29,8 +33,8 @@ import com.squareup.workflow1.compose.WorkflowComposableRenderer
29
33
import com.squareup.workflow1.identifier
30
34
import com.squareup.workflow1.internal.IdCounter
31
35
import com.squareup.workflow1.internal.WorkflowNodeId
32
- import com.squareup.workflow1.internal.requireSend
33
36
import com.squareup.workflow1.internal.createId
37
+ import com.squareup.workflow1.internal.requireSend
34
38
import com.squareup.workflow1.workflowSessionToString
35
39
import kotlinx.coroutines.CoroutineName
36
40
import kotlinx.coroutines.CoroutineScope
@@ -96,6 +100,8 @@ internal class ComposeWorkflowChildNode<PropsT, OutputT, RenderingT>(
96
100
}
97
101
}
98
102
103
+ private var lastProps by mutableStateOf(initialProps)
104
+
99
105
/* *
100
106
* Function invoked when [onNextAction] receives an output from [outputsChannel].
101
107
*/
@@ -149,6 +155,9 @@ internal class ComposeWorkflowChildNode<PropsT, OutputT, RenderingT>(
149
155
// inside a renderChild call and renderChild does the keying.
150
156
log(" rendering workflow: props=$props " )
151
157
workflow as ComposeWorkflow
158
+
159
+ notifyInterceptorWhenPropsChanged(props)
160
+
152
161
return withCompositionLocals(
153
162
LocalSaveableStateRegistry provides saveableStateRegistry,
154
163
LocalWorkflowComposableRenderer provides this
@@ -167,6 +176,22 @@ internal class ComposeWorkflowChildNode<PropsT, OutputT, RenderingT>(
167
176
}
168
177
}
169
178
179
+ @ReadOnlyComposable
180
+ @NonRestartableComposable
181
+ @Composable
182
+ private fun notifyInterceptorWhenPropsChanged (newProps : PropsT ) {
183
+ if (lastProps != newProps) {
184
+ interceptor.onPropsChanged(
185
+ old = lastProps,
186
+ new = newProps,
187
+ state = ComposeWorkflowState ,
188
+ session = this ,
189
+ proceed = { _, _, _ -> ComposeWorkflowState },
190
+ )
191
+ lastProps = newProps
192
+ }
193
+ }
194
+
170
195
@Composable
171
196
override fun <ChildPropsT , ChildOutputT , ChildRenderingT > renderChild (
172
197
childWorkflow : Workflow <ChildPropsT , ChildOutputT , ChildRenderingT >,
0 commit comments