WorkflowBuilder
@available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *)
@resultBuilder
public enum WorkflowBuilder
Used to build a Workflow
in SwiftUI; Embed WorkflowItem
s in a WorkflowBuilder
to define your workflow.
Discussion
Typically, you’ll use this when you use WorkflowView
. Otherwise you might use it as a way to build your own workflows in a wrapper type.
Example
WorkflowView(isLaunched: $isLaunched.animation(), launchingWith: "String in") {
WorkflowItem(FirstView.self)
WorkflowItem(SecondView.self)
}
.onAbandon { print("isLaunched is now false") }
.onFinish { args in print("Finished 1: \(args)") }
.onFinish { print("Finished 2: \($0)") }
.background(Color.green)
NOTE
There is a Swift-imposed limit on how many items we can have in a WorkflowBuilder
. Similar to SwiftUI’s ViewBuilder, WorkflowBuilder
has a limit of 10 items. Just like you can use Group
in SwiftUI you can use WorkflowGroup
to get around that 10 item limit with SwiftCurrent.
-
Declaration
Swift
public static func buildOptional<W>(_ component: W?) -> OptionalWorkflowItem<W> where W : _WorkflowItemProtocol
-
Declaration
Swift
public static func buildEither<TrueCondition, FalseCondition>(first component: TrueCondition) -> EitherWorkflowItem<TrueCondition, FalseCondition> where TrueCondition : _WorkflowItemProtocol, FalseCondition : _WorkflowItemProtocol, TrueCondition.FlowRepresentableType.WorkflowInput == FalseCondition.FlowRepresentableType.WorkflowInput
-
Declaration
Swift
public static func buildEither<TrueCondition, FalseCondition>(second component: FalseCondition) -> EitherWorkflowItem<TrueCondition, FalseCondition> where TrueCondition : _WorkflowItemProtocol, FalseCondition : _WorkflowItemProtocol, TrueCondition.FlowRepresentableType.WorkflowInput == FalseCondition.FlowRepresentableType.WorkflowInput
-
Declaration
Swift
public static func buildBlock<W0>(_ w0: W0) -> WorkflowItemWrapper<W0, Never> where W0 : _WorkflowItemProtocol
-
Declaration
Swift
public static func buildBlock<W0: _WorkflowItemProtocol, W1: _WorkflowItemProtocol>(_ w0: W0, _ w1: W1) -> WorkflowItemWrapper<W0, WorkflowItemWrapper<W1, Never>>
-
Declaration
Swift
public static func buildBlock<W0: _WorkflowItemProtocol, W1: _WorkflowItemProtocol, W2: _WorkflowItemProtocol>(_ w0: W0, _ w1: W1, _ w2: W2) -> WorkflowItemWrapper<W0, WorkflowItemWrapper<W1, WorkflowItemWrapper<W2, Never>>>
-
Declaration
Swift
public static func buildBlock<W0: _WorkflowItemProtocol, W1: _WorkflowItemProtocol, W2: _WorkflowItemProtocol, W3: _WorkflowItemProtocol>(_ w0: W0, _ w1: W1, _ w2: W2, _ w3: W3) -> WorkflowItemWrapper<W0, WorkflowItemWrapper<W1, WorkflowItemWrapper<W2, WorkflowItemWrapper<W3, Never>>>>
-
Declaration
Swift
public static func buildBlock<W0: _WorkflowItemProtocol, W1: _WorkflowItemProtocol, W2: _WorkflowItemProtocol, W3: _WorkflowItemProtocol, W4: _WorkflowItemProtocol>(_ w0: W0, _ w1: W1, _ w2: W2, _ w3: W3, _ w4: W4) -> WorkflowItemWrapper<W0, WorkflowItemWrapper<W1, WorkflowItemWrapper<W2, WorkflowItemWrapper<W3, WorkflowItemWrapper<W4, Never>>>>>
-
Declaration
Swift
public static func buildBlock<W0: _WorkflowItemProtocol, W1: _WorkflowItemProtocol, W2: _WorkflowItemProtocol, W3: _WorkflowItemProtocol, W4: _WorkflowItemProtocol, W5: _WorkflowItemProtocol>(_ w0: W0, _ w1: W1, _ w2: W2, _ w3: W3, _ w4: W4, _ w5: W5) -> WorkflowItemWrapper<W0, WorkflowItemWrapper<W1, WorkflowItemWrapper<W2, WorkflowItemWrapper<W3, WorkflowItemWrapper<W4, WorkflowItemWrapper<W5, Never>>>>>>
-
Declaration
Swift
public static func buildBlock<W0: _WorkflowItemProtocol, W1: _WorkflowItemProtocol, W2: _WorkflowItemProtocol, W3: _WorkflowItemProtocol, W4: _WorkflowItemProtocol, W5: _WorkflowItemProtocol, W6: _WorkflowItemProtocol>(_ w0: W0, _ w1: W1, _ w2: W2, _ w3: W3, _ w4: W4, _ w5: W5, _ w6: W6) -> WorkflowItemWrapper<W0, WorkflowItemWrapper<W1, WorkflowItemWrapper<W2, WorkflowItemWrapper<W3, WorkflowItemWrapper<W4, WorkflowItemWrapper<W5, WorkflowItemWrapper<W6, Never>>>>>>>
-
Declaration
Swift
public static func buildBlock<W0: _WorkflowItemProtocol, W1: _WorkflowItemProtocol, W2: _WorkflowItemProtocol, W3: _WorkflowItemProtocol, W4: _WorkflowItemProtocol, W5: _WorkflowItemProtocol, W6: _WorkflowItemProtocol, W7: _WorkflowItemProtocol>(_ w0: W0, _ w1: W1, _ w2: W2, _ w3: W3, _ w4: W4, _ w5: W5, _ w6: W6, _ w7: W7) -> WorkflowItemWrapper<W0, WorkflowItemWrapper<W1, WorkflowItemWrapper<W2, WorkflowItemWrapper<W3, WorkflowItemWrapper<W4, WorkflowItemWrapper<W5, WorkflowItemWrapper<W6, WorkflowItemWrapper<W7, Never>>>>>>>>
-
Declaration
Swift
public static func buildBlock<W0: _WorkflowItemProtocol, W1: _WorkflowItemProtocol, W2: _WorkflowItemProtocol, W3: _WorkflowItemProtocol, W4: _WorkflowItemProtocol, W5: _WorkflowItemProtocol, W6: _WorkflowItemProtocol, W7: _WorkflowItemProtocol, W8: _WorkflowItemProtocol>(_ w0: W0, _ w1: W1, _ w2: W2, _ w3: W3, _ w4: W4, _ w5: W5, _ w6: W6, _ w7: W7, _ w8: W8) -> WorkflowItemWrapper<W0, WorkflowItemWrapper<W1, WorkflowItemWrapper<W2, WorkflowItemWrapper<W3, WorkflowItemWrapper<W4, WorkflowItemWrapper<W5, WorkflowItemWrapper<W6, WorkflowItemWrapper<W7, WorkflowItemWrapper<W8, Never>>>>>>>>>
-
Declaration
Swift
public static func buildBlock<W0: _WorkflowItemProtocol, W1: _WorkflowItemProtocol, W2: _WorkflowItemProtocol, W3: _WorkflowItemProtocol, W4: _WorkflowItemProtocol, W5: _WorkflowItemProtocol, W6: _WorkflowItemProtocol, W7: _WorkflowItemProtocol, W8: _WorkflowItemProtocol, W9: _WorkflowItemProtocol>(_ w0: W0, _ w1: W1, _ w2: W2, _ w3: W3, _ w4: W4, _ w5: W5, _ w6: W6, _ w7: W7, _ w8: W8, _ w9: W9) -> WorkflowItemWrapper<W0, WorkflowItemWrapper<W1, WorkflowItemWrapper<W2, WorkflowItemWrapper<W3, WorkflowItemWrapper<W4, WorkflowItemWrapper<W5, WorkflowItemWrapper<W6, WorkflowItemWrapper<W7, WorkflowItemWrapper<W8, WorkflowItemWrapper<W9, Never>>>>>>>>>>