diff --git a/Tooling/Templates/Workflow (Verbose).xctemplate/___FILEBASENAME___Workflow.swift b/Tooling/Templates/Workflow (Verbose).xctemplate/Default/___FILEBASENAME___Workflow.swift similarity index 77% rename from Tooling/Templates/Workflow (Verbose).xctemplate/___FILEBASENAME___Workflow.swift rename to Tooling/Templates/Workflow (Verbose).xctemplate/Default/___FILEBASENAME___Workflow.swift index f72f25a79..f4b44cda9 100644 --- a/Tooling/Templates/Workflow (Verbose).xctemplate/___FILEBASENAME___Workflow.swift +++ b/Tooling/Templates/Workflow (Verbose).xctemplate/Default/___FILEBASENAME___Workflow.swift @@ -1,8 +1,6 @@ // ___FILEHEADER___ -import ReactiveSwift import Workflow -import WorkflowReactiveSwift import WorkflowUI // MARK: Input and Output @@ -37,22 +35,6 @@ extension ___VARIABLE_productName___Workflow { } } -// MARK: Workers - -extension ___VARIABLE_productName___Workflow { - struct ___VARIABLE_productName___Worker: Worker { - enum Output {} - - func run() -> SignalProducer { - fatalError() - } - - func isEquivalent(to otherWorker: ___VARIABLE_productName___Worker) -> Bool { - return true - } - } -} - // MARK: Rendering extension ___VARIABLE_productName___Workflow { diff --git a/Tooling/Templates/Workflow (Verbose).xctemplate/TemplateInfo.plist b/Tooling/Templates/Workflow (Verbose).xctemplate/TemplateInfo.plist index 25f79240a..815ea6d76 100644 --- a/Tooling/Templates/Workflow (Verbose).xctemplate/TemplateInfo.plist +++ b/Tooling/Templates/Workflow (Verbose).xctemplate/TemplateInfo.plist @@ -18,12 +18,52 @@ Name Name: Description - The name of the workflow to create. "Workflow" will be appended to the name. + The name of the workflow to create. "Workflow" will be appended to the name. Type text Default HelloWorld + + Identifier + generateWorker + Required + + Name + Also create a Worker + Description + Workers define a unit of asynchronous work + Type + checkbox + Default + false + + + Identifier + streamType + Required + + Name + Uses: + Description + Whether to use RxSwift or ReactiveSwift + Type + popup + Default + ReactiveSwift + RequiredOptions + + generateWorker + + true + + + Values + + RxSwift + ReactiveSwift + + diff --git a/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerReactiveSwift/___FILEBASENAME___Worker.swift b/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerReactiveSwift/___FILEBASENAME___Worker.swift new file mode 100644 index 000000000..c6c66aea8 --- /dev/null +++ b/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerReactiveSwift/___FILEBASENAME___Worker.swift @@ -0,0 +1,22 @@ +// ___FILEHEADER___ + +import ReactiveSwift +import Workflow +import WorkflowReactiveSwift +import WorkflowUI + +// MARK: Workers + +extension ___VARIABLE_productName___Workflow { + struct ___VARIABLE_productName___Worker: Worker { + enum Output {} + + func run() -> SignalProducer { + fatalError() + } + + func isEquivalent(to otherWorker: ___VARIABLE_productName___Worker) -> Bool { + return true + } + } +} diff --git a/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerReactiveSwift/___FILEBASENAME___Workflow.swift b/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerReactiveSwift/___FILEBASENAME___Workflow.swift new file mode 100644 index 000000000..f4b44cda9 --- /dev/null +++ b/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerReactiveSwift/___FILEBASENAME___Workflow.swift @@ -0,0 +1,48 @@ +// ___FILEHEADER___ + +import Workflow +import WorkflowUI + +// MARK: Input and Output + +struct ___VARIABLE_productName___Workflow: Workflow { + enum Output {} +} + +// MARK: State and Initialization + +extension ___VARIABLE_productName___Workflow { + struct State {} + + func makeInitialState() -> ___VARIABLE_productName___Workflow.State { + return State() + } + + func workflowDidChange(from previousWorkflow: ___VARIABLE_productName___Workflow, state: inout State) {} +} + +// MARK: Actions + +extension ___VARIABLE_productName___Workflow { + enum Action: WorkflowAction { + typealias WorkflowType = ___VARIABLE_productName___Workflow + + func apply(toState state: inout ___VARIABLE_productName___Workflow.State) -> ___VARIABLE_productName___Workflow.Output? { + switch self { + // Update state and produce an optional output based on which action was received. + } + } + } +} + +// MARK: Rendering + +extension ___VARIABLE_productName___Workflow { + // TODO: Change this to your actual rendering type + typealias Rendering = String + + func render(state: ___VARIABLE_productName___Workflow.State, context: RenderContext<___VARIABLE_productName___Workflow>) -> Rendering { + #warning("Don't forget your render implementation and to return the correct rendering type!") + return "This is likely not the rendering that you want to return" + } +} diff --git a/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerRxSwift/___FILEBASENAME___Worker.swift b/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerRxSwift/___FILEBASENAME___Worker.swift new file mode 100644 index 000000000..ac6491969 --- /dev/null +++ b/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerRxSwift/___FILEBASENAME___Worker.swift @@ -0,0 +1,22 @@ +// ___FILEHEADER___ + +import RxSwift +import Workflow +import WorkflowRxSwift +import WorkflowUI + +// MARK: Workers + +extension ___VARIABLE_productName___Workflow { + struct ___VARIABLE_productName___Worker: Worker { + enum Output {} + + func run() -> Observable { + fatalError() + } + + func isEquivalent(to otherWorker: ___VARIABLE_productName___Worker) -> Bool { + return true + } + } +} diff --git a/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerRxSwift/___FILEBASENAME___Workflow.swift b/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerRxSwift/___FILEBASENAME___Workflow.swift new file mode 100644 index 000000000..f4b44cda9 --- /dev/null +++ b/Tooling/Templates/Workflow (Verbose).xctemplate/generateWorkerRxSwift/___FILEBASENAME___Workflow.swift @@ -0,0 +1,48 @@ +// ___FILEHEADER___ + +import Workflow +import WorkflowUI + +// MARK: Input and Output + +struct ___VARIABLE_productName___Workflow: Workflow { + enum Output {} +} + +// MARK: State and Initialization + +extension ___VARIABLE_productName___Workflow { + struct State {} + + func makeInitialState() -> ___VARIABLE_productName___Workflow.State { + return State() + } + + func workflowDidChange(from previousWorkflow: ___VARIABLE_productName___Workflow, state: inout State) {} +} + +// MARK: Actions + +extension ___VARIABLE_productName___Workflow { + enum Action: WorkflowAction { + typealias WorkflowType = ___VARIABLE_productName___Workflow + + func apply(toState state: inout ___VARIABLE_productName___Workflow.State) -> ___VARIABLE_productName___Workflow.Output? { + switch self { + // Update state and produce an optional output based on which action was received. + } + } + } +} + +// MARK: Rendering + +extension ___VARIABLE_productName___Workflow { + // TODO: Change this to your actual rendering type + typealias Rendering = String + + func render(state: ___VARIABLE_productName___Workflow.State, context: RenderContext<___VARIABLE_productName___Workflow>) -> Rendering { + #warning("Don't forget your render implementation and to return the correct rendering type!") + return "This is likely not the rendering that you want to return" + } +}