wwt / SwiftCurrent

A library for managing complex workflows in Swift

Home Page:https://wwt.github.io/SwiftCurrent/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Passthrough` FlowRepresentable

Tyler-Keith-Thompson opened this issue · comments

Is your feature request related to a problem? Please describe.

Not so much a problem, just an idea

Describe the solution you'd like

Idea: We could have a Passthrough type that's a little different than Never. Whereas Never means "I don't take in a value" or "I don't pass out a value". Passthrough could mean "I'll forward on anything that gets passed to me automatically`.

Hypothetical: Imagine a workflow wherein you've got a terms and conditions FlowRepresentable. Now it knows whether terms have been accepted or not, and it will make the decision to abandon whatever workflow it is in if the terms are not accepted. However if terms are accepted it might send that information to a server then move forward.

If that termsAndConditions had a Passthrough type for its input and output it would be even easier to stick those terms and conditions in any workflow while maintaining type safety of that flow.

Describe alternatives you've considered

I mean users can do this now, manually. So they could continue to do it manually. Something like:

struct FR1: FlowRepresentable {
    typealias WorkflowOutput = AnyWorkflow.PassedArgs
    var _workflowPointer: AnyFlowRepresentable?
    var passedArgs: AnyWorkflow.PassedArgs
    init(with args: AnyWorkflow.PassedArgs) {
        passedArgs = args
    }
    
    func doAThing() {
        proceedInWorkflow(passedArgs)
    }
}

That's just a lot of boilerplate

I like the idea, but we may not get to it right away as we're focused on the SwiftUI milestone.

@wiemerm @Tyler-Keith-Thompson is this in main already? I thought I saw a pass through type.

It is not. At least not as intended with the feature request. The point is to remove the boilerplate of having to set input and output to AnyWorkflow.PassedArgs and then storing data and passing it forward on a proceed.

I don’t think it’ll be a difficult addition, though