-
Notifications
You must be signed in to change notification settings - Fork 47
[feat]: give AnyWorkflow a Workflow conformance #184
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
7 commits
Select commit
Hold shift + click to select a range
9be6a82
[WIP]: adds Workflow conformance to AnyWorkflow
jamieQ eb623fb
cleanup & tests
jamieQ 67393fe
more tests
jamieQ a4de618
Merge remote-tracking branch 'origin/main' into jquadri/exp-anyworkfl…
jamieQ 296893d
expose erased workflow property in AnyWorkflow
jamieQ 3e9b3a4
tests
jamieQ fae80e6
more tests
jamieQ 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 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 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 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 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 |
---|---|---|
|
@@ -29,7 +29,7 @@ public final class WorkflowHostingController<ScreenType, Output>: UIViewControll | |
|
||
private(set) var rootViewController: UIViewController | ||
|
||
private let workflowHost: WorkflowHost<RootWorkflow<ScreenType, Output>> | ||
private let workflowHost: WorkflowHost<AnyWorkflow<ScreenType, Output>> | ||
|
||
private let (lifetime, token) = Lifetime.make() | ||
|
||
|
@@ -45,7 +45,7 @@ public final class WorkflowHostingController<ScreenType, Output>: UIViewControll | |
observers: [WorkflowObserver] = [] | ||
) where W.Rendering == ScreenType, W.Output == Output { | ||
self.workflowHost = WorkflowHost( | ||
workflow: RootWorkflow(workflow), | ||
workflow: workflow.asAnyWorkflow(), | ||
observers: observers | ||
) | ||
|
||
|
@@ -74,7 +74,7 @@ public final class WorkflowHostingController<ScreenType, Output>: UIViewControll | |
|
||
/// Updates the root Workflow in this container. | ||
public func update<W: AnyWorkflowConvertible>(workflow: W) where W.Rendering == ScreenType, W.Output == Output { | ||
workflowHost.update(workflow: RootWorkflow(workflow)) | ||
workflowHost.update(workflow: workflow.asAnyWorkflow()) | ||
} | ||
|
||
public required init?(coder aDecoder: NSCoder) { | ||
|
@@ -150,25 +150,4 @@ public final class WorkflowHostingController<ScreenType, Output>: UIViewControll | |
} | ||
} | ||
|
||
/// Wrapper around an AnyWorkflow that allows us to have a concrete | ||
/// WorkflowHost without WorkflowHostingController itself being generic | ||
/// around a Workflow. | ||
fileprivate struct RootWorkflow<Rendering, Output>: Workflow { | ||
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. no longer necessary |
||
typealias State = Void | ||
typealias Output = Output | ||
typealias Rendering = Rendering | ||
|
||
var wrapped: AnyWorkflow<Rendering, Output> | ||
|
||
init<W: AnyWorkflowConvertible>(_ wrapped: W) where W.Rendering == Rendering, W.Output == Output { | ||
self.wrapped = wrapped.asAnyWorkflow() | ||
} | ||
|
||
func render(state: State, context: RenderContext<RootWorkflow>) -> Rendering { | ||
return wrapped | ||
.mapOutput { AnyWorkflowAction(sendingOutput: $0) } | ||
.rendered(in: context) | ||
} | ||
} | ||
|
||
#endif |
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.
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.
is there a way to get the compiler to do this without having to perform the runtime check?