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
Adds Passthrough representable #79
Conversation
…assthroughFlowRepresentable, works good so far - TT
…generic constraints, still have 3 to uncomment and get compiling - TT Co-authored-by: Tyler Thompson <tyler.thompson@wwt.com>
…c constraints in tests, including passthrough representables - TT Co-authored-by: Tyler Thompson <tyler.thompson@wwt.com>
…ods with thenProceedWith methods so that the API surface is easier to keep track of - TT Co-authored-by: Tyler Thompson <tyler.thompson@wwt.com>
…rrectly - TT Co-authored-by: Tyler Thompson <tyler.thompson@wwt.com>
…ed fix on everything, then reveled in how effective that was. API upgrade path tested - TT Co-authored-by: Tyler Thompson <tyler.thompson@wwt.com>
…ion replaces we are up and running with SwiftUI generic constraint tests - TT Co-authored-by: Tyler Thompson <tyler.thompson@wwt.com>
… out, we should be all set now - TT Co-authored-by: Tyler Thompson <tyler.thompson@wwt.com>
Codecov Report
@@ Coverage Diff @@
## main #79 +/- ##
==========================================
- Coverage 98.49% 97.76% -0.73%
==========================================
Files 86 89 +3
Lines 3844 5095 +1251
==========================================
+ Hits 3786 4981 +1195
- Misses 58 114 +56
Continue to review full report at Codecov.
|
Alternative Approaches Considered:
Design Choices:
|
NOTE:
|
Rules for Generic Constraints
In UIKitValid Workflows FORMAT: {LAUNCH_ARGS} >> INPUT>Output ~> Next Item
Compile time works, but fails at runtime:
In SwiftUIValid Workflows FORMAT: {LAUNCH_ARGS} >> INPUT>Output ~> Next Item
Compile time works, but fails at runtime:
Invalid Workflows that could've worked in UIKit
|
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.
Looks good so far, but I want to play with it a bit before I sign off.
The failed test after the merge was due to an exceeded timeout in |
Missing: PassthroughFlowRepresentable does not yet play nice with StoryboardLoadable |
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.
Having PassthroughFlowRepresentable work with StoryboardLoadable is going to be a requirement for me. Without it, I can't use it in our example app to showcase a simple way to leverage it.
Co-authored-by: Tyler Thompson <Tyler.Thompson@wwt.com>
So I'm trying to test it with our example app: class TermsOfServiceViewController: UIViewController, PassthroughFlowRepresentable, StoryboardLoadable {
weak var _workflowPointer: AnyFlowRepresentable?
@IBAction private func accept(_ sender: Any) {
proceedInWorkflow()
}
} And when I add it to the SetupViewController: launchInto(
Workflow(LocationsViewController.self)
.thenProceed(with: PickupOrDeliveryViewController.self)
.thenProceed(with: TermsOfServiceViewController.self) // <----- just added it in the middle somewhere
.thenProceed(with: MenuSelectionViewController.self, flowPersistence: .persistWhenSkipped)
.thenProceed(with: FoodSelectionViewController.self)
.thenProceed(with: ReviewOrderViewController.self),
args: locations,
withLaunchStyle: .navigationStack) I get a fatalError when it is time to show the screen: You may find it helpful to go ahead and add a ToS screen to the example app to test out consuming it in a Storyboards example. It would also give your feature a cool shoutout on why it's awesome. |
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.
Found a typo. If this was a copy paste thing, it's ok to just update this code, but updating where you copied it from would be appreciated.
…h on storyboard loadable - TT Co-authored-by: Tyler Thompson <Tyler.Thompson@wwt.com>
I'm still having trouble using this in the UIKitExample app. Using the code I posted above, here's the results: Simulator.Screen.Recording.-.iPod.touch.7th.generation.-.2021-07-26.at.13.06.53.mp4 |
Woah...there was a deep underlying issue with SwiftCurrent altogether here. Short version? When the input type was I can try to fix that as part of this issue, but it feels like this'll get stuck on behalf of a bug that has nothing to do with this new feature for a while. |
Code that is the problem, in AnyFlowRepresentable.swift /**
Creates an erased `FlowRepresentable` by using its initializer
- Parameter type: The `FlowRepresentable` type to create an instance of
- Parameter args: The `AnyWorkflow.PassedArgs` to create the instance with. This ends up being cast into the `FlowRepresentable.WorkflowInput`.
*/
public init<FR: FlowRepresentable>(_ type: FR.Type, args: AnyWorkflow.PassedArgs) {
argsHolder = args
switch args {
case _ where FR.WorkflowInput.self == Never.self:
var instance = FR._factory(FR.self)
_storage = AnyFlowRepresentableStorage(&instance)
case _ where FR.WorkflowInput.self == AnyWorkflow.PassedArgs.self:
// swiftlint:disable:next force_cast
var instance = FR(with: args as! FR.WorkflowInput) // <-- THIS IS WRONG
_storage = AnyFlowRepresentableStorage(&instance)
case .args(let extracted):
guard let cast = extracted as? FR.WorkflowInput else { fatalError("TYPE MISMATCH: \(String(describing: args)) is not type: \(FR.WorkflowInput.self)") }
var instance = FR._factory(FR.self, with: cast)
_storage = AnyFlowRepresentableStorage(&instance)
default: fatalError("No arguments were passed to representable: \(FR.self), but it expected: \(FR.WorkflowInput.self)")
}
_storage._workflowPointer = self
isPassthrough = FR.self is _PassthroughIdentifiable.Type
} |
Wow that's not great. Thank you for tracking that down. I've already created an Issue to fix that particular bug from your comment. |
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.
Having PassthroughFlowRepresentable work with StoryboardLoadable is going to be a requirement for me. Without it, I can't use it in our example app to showcase a simple way to leverage it.
Since you tracked this down to a pre-existing bug that is now tracked with issue #80 , I'm good with what I've reviewed.
@wiemerm When you're good with this could you ramp the minor version? This enhances the API so we should do a minor bump, but it's not a breaking change so no need for a major bump. |
5a1698e
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.
Thank you @wiemerm
Linked Issue: Closes #21
Checklist:
If Public API Has Changed: