-
Notifications
You must be signed in to change notification settings - Fork 18
Launching a Workflow using an AnyWorkflow #150
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ebc902f
[launch-with-workflow] - Added FlowRepresentableMetadataTests, made F…
morganzellers 21a62c8
[launch-with-workflow] - Added tests for new launcher initializer usi…
morganzellers 41474c3
Adding support for .last computed property to AnyWorkflow
morganzellers e5b0e64
Adds support for workflows with more than one item.
morganzellers b3c2c6b
Refactor of ExtendedFlowRepresentableMetadata inits and function to f…
morganzellers 402a9fe
Added test for fatalError scenario in which no items in a workflow
morganzellers e67d734
WIP - Working through the tests and adding thenProceeds as I figure i…
morganzellers 3e70c53
WIP still - added more thenProceeds but still have a lot to drive out.
morganzellers 686cf28
Adds support for launching a workflow using an AnyWorkflow with start…
morganzellers 1d51a0a
Added generic constraint test file for AnyWorkflow launched Workflows.
morganzellers 4000010
WIP - Using generic constraints tests to drive out more thenProceeds.
morganzellers 3a2a9c4
[launch-with-workflow] - Adding missing init that was causing tests t…
Richard-Gist f87bbe7
[launch-with-workflow] - Fixing linting error - RAG
Richard-Gist d9e7845
[launch-with-workflow] - Fixed some linting and got some tests passin…
Richard-Gist 9c786ca
Merge branch 'data-driven' into launch-with-workflow
morganzellers f585656
[launch-with-workflow] - Removed tests for thenProceed functions only…
morganzellers ff16c99
[launch-with-workflow] - Adding more descriptive docs - RAG MZ
morganzellers 1f62b9b
[launch-with-workflow] - Added TODO to make public Workflow inits pri…
morganzellers 9a283fd
Taking Richard's whitespace fix
morganzellers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
240 changes: 240 additions & 0 deletions
240
Sources/SwiftCurrent_SwiftUI/Extensions/WorkflowExtensions.swift
Large diffs are not rendered by default.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
Sources/SwiftCurrent_SwiftUI/Models/ExtendedFlowRepresentableMetadata.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // | ||
| // ExtendedFlowRepresentableMetadata.swift | ||
| // SwiftCurrent | ||
| // | ||
| // Created by Morgan Zellers on 11/2/21. | ||
| // Copyright © 2021 WWT and Tyler Thompson. All rights reserved. | ||
| // | ||
|
|
||
| import SwiftUI | ||
| import SwiftCurrent | ||
|
|
||
| @available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *) | ||
| class ExtendedFlowRepresentableMetadata: FlowRepresentableMetadata { | ||
| private(set) var workflowItemFactory: (AnyWorkflowItem?) -> AnyWorkflowItem | ||
|
|
||
| init<FR: FlowRepresentable & View>(flowRepresentableType: FR.Type, | ||
| launchStyle: LaunchStyle = .default, | ||
| flowPersistence: @escaping (AnyWorkflow.PassedArgs) -> FlowPersistence, | ||
| flowRepresentableFactory: @escaping (AnyWorkflow.PassedArgs) -> AnyFlowRepresentable) { | ||
| workflowItemFactory = { | ||
| guard let wrappedWorkflowItem = $0 else { return AnyWorkflowItem(view: WorkflowItem(FR.self)) } | ||
| return AnyWorkflowItem(view: WorkflowItem(FR.self) { wrappedWorkflowItem }) | ||
| } | ||
|
|
||
| super.init(flowRepresentableType, launchStyle: launchStyle, flowPersistence: flowPersistence, flowRepresentableFactory: flowRepresentableFactory) | ||
| } | ||
|
|
||
| init<FR: FlowRepresentable & View>(flowRepresentableType: FR.Type, | ||
| launchStyle: LaunchStyle = .default, | ||
| flowPersistence: @escaping (AnyWorkflow.PassedArgs) -> FlowPersistence) { | ||
| workflowItemFactory = { | ||
| guard let wrappedWorkflowItem = $0 else { return AnyWorkflowItem(view: WorkflowItem(FR.self)) } | ||
| return AnyWorkflowItem(view: WorkflowItem(FR.self) { wrappedWorkflowItem }) | ||
| } | ||
|
|
||
| super.init(flowRepresentableType, launchStyle: launchStyle, flowPersistence: flowPersistence) { args in | ||
| AnyFlowRepresentableView(type: FR.self, args: args) | ||
| } | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
Sources/SwiftCurrent_SwiftUI/TypeErased/AnyWorkflowItem.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // | ||
| // AnyWorkflowItem.swift | ||
| // SwiftCurrent | ||
| // | ||
| // Created by Morgan Zellers on 11/2/21. | ||
| // Copyright © 2021 WWT and Tyler Thompson. All rights reserved. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| @available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *) | ||
| public struct AnyWorkflowItem: View { | ||
| let inspection = Inspection<Self>() | ||
| private let _body: AnyView | ||
|
|
||
| public var body: some View { | ||
| _body.onReceive(inspection.notice) { inspection.visit(self, $0) } | ||
| } | ||
|
|
||
| init<F, W, C>(view: WorkflowItem<F, W, C>) { | ||
| _body = AnyView(view) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Tests/SwiftCurrentTests/FlowRepresentableMetadataConsumerTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // | ||
| // FlowRepresentableMetadataConsumerTests.swift | ||
| // SwiftCurrent | ||
| // | ||
| // Created by Morgan Zellers on 11/2/21. | ||
| // Copyright © 2021 WWT and Tyler Thompson. All rights reserved. | ||
| // | ||
|
|
||
| import XCTest | ||
| import SwiftCurrent | ||
|
|
||
| class FlowRepresentableMetadataConsumerTests: XCTestCase { | ||
| func testOverridingFlowRepresentbleMetadata() { | ||
| class SpecialConformanceClass { } | ||
|
|
||
| class NewMetadata: FlowRepresentableMetadata { | ||
| var wf: String? // AnyWFItem | ||
|
|
||
| private override init<FR>(_ flowRepresentableType: FR.Type, launchStyle: LaunchStyle = .default, flowPersistence: @escaping (AnyWorkflow.PassedArgs) -> FlowPersistence, flowRepresentableFactory: @escaping (AnyWorkflow.PassedArgs) -> AnyFlowRepresentable) where FR : FlowRepresentable { | ||
|
|
||
|
|
||
| super.init(flowRepresentableType, launchStyle: launchStyle, flowPersistence: flowPersistence, flowRepresentableFactory: flowRepresentableFactory) | ||
| } | ||
|
|
||
| convenience init<FR: FlowRepresentable & SpecialConformanceClass>(flowRepresentableType: FR.Type, launchStyle: LaunchStyle = .default, flowPersistence: @escaping (AnyWorkflow.PassedArgs) -> FlowPersistence, flowRepresentableFactory: @escaping (AnyWorkflow.PassedArgs) -> AnyFlowRepresentable) { | ||
|
|
||
| self.init(flowRepresentableType, launchStyle: launchStyle, flowPersistence: flowPersistence, flowRepresentableFactory: flowRepresentableFactory) | ||
|
|
||
| wf = String(describing: flowRepresentableType) | ||
| } | ||
| } | ||
|
|
||
| final class FR1: SpecialConformanceClass, FlowRepresentable { | ||
| var _workflowPointer: AnyFlowRepresentable? | ||
| } | ||
|
|
||
| let _ = NewMetadata(flowRepresentableType: FR1.self, | ||
| flowPersistence: { _ in .default }) { _ in | ||
| AnyFlowRepresentable(FR1.self, args: .none) | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.