-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[chore]: refactor some internal actions to use existential any #190
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,9 +48,19 @@ final class WorkflowNode<WorkflowType: Workflow> { | |
let output: Output | ||
|
||
switch subtreeOutput { | ||
case .update(let event, let source): | ||
/// Apply the update to the current state | ||
let outputEvent = event.apply(toState: &state) | ||
case .update(let action, let source): | ||
|
||
/// 'Opens' the existential `any WorkflowAction<WorkflowType>` value | ||
/// allowing the underlying conformance to be applied to the Workflow's State | ||
func openAndApply<A: WorkflowAction>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not entirely clear to me why this is necessary, or exactly why it works, but if you try to invoke |
||
_ action: A, | ||
to state: inout WorkflowType.State | ||
) -> WorkflowType.Output? where A.WorkflowType == WorkflowType { | ||
/// Apply the update to the current state | ||
action.apply(toState: &state) | ||
} | ||
|
||
let outputEvent = openAndApply(action, to: &state) | ||
|
||
/// Finally, we tell the outside world that our state has changed (including an output event if it exists). | ||
output = Output( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change will help the observation API be more useful as we will be able to expose the underlying conformance and not an AnyWorkflow wrapper