You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[feat]: add runtime option to skip render if state is inferred to be unchanged (#364)
adds support to conditionally opt in a WorkflowHost runtime to use a
render-skipping optimization that checks if we can reasonably infer that
no workflow node state was changed during a series of action
applications. if the inference indicates no state has changed, the
render pass will be skipped. the changes made to support this include:
- adding a new `ActionApplicationResult` type to model the result of
applying an action to a node. this type carries some invalidation state
information with it to propagate up the tree.
- adding new conditional logic into the `applyAction()` method (renamed
from `openAndApply()`) to conditionally try to infer if state has
changed under the following conditions:
- if the `State` instance can be dynamically inferred to be `Equatable`,
then the before & after values will be compared to determine if the
update should be treated as invalidating state or not
- if the type of `State` is equivalent to `Void`, then it will be
treated as never having changed
- if the sequence of action applications makes it to the root node and
the final `ActionApplicationResult` indicates that no state was changed,
the root node will skip the subsequent render pass. note: if an output
event is produced, that will still be delivered and is independent of
this logic.
this change has the potential to alter observable behavior, and so is
opt-in behind a conditional runtime configuration option.
primary changes:
- `WorkflowNode.applyAction()`
- `WorkflowHost.handle()`
/// The possible output types that a SubtreeManager can produce.
158
159
enumOutput{
159
-
case update(anyWorkflowAction<WorkflowType>, source:EventSource)
160
-
case childDidUpdate(WorkflowUpdateDebugInfo?)
160
+
/// Indicates that an event produced a `WorkflowAction` to apply to the node.
161
+
///
162
+
/// - Parameters:
163
+
/// - action: The `WorkflowAction` to be applied to the node.
164
+
/// - source: The event source that triggered this update. This is primarily used to differentiate between 'external' events and events that originate from the subtree itself.
165
+
/// - subtreeInvalidated: A boolean indicating whether at least one descendant workflow has been invalidated during this update.
166
+
case update(
167
+
anyWorkflowAction<WorkflowType>,
168
+
source:EventSource,
169
+
subtreeInvalidated:Bool
170
+
)
171
+
172
+
/// Indicates that a child workflow within the subtree handled an event and was updated. This informs the parent node about the change and propagates the update 'up' the tree.
173
+
///
174
+
/// - Parameters:
175
+
/// - debugInfo: Optional debug information about the workflow update.
176
+
/// - subtreeInvalidated: A boolean indicating whether at least one descendant workflow has been invalidated during this update.
0 commit comments