From 102db8289f01f9d108a00a134b642ccd0541d723 Mon Sep 17 00:00:00 2001 From: Tyler Stromberg Date: Thu, 10 Sep 2020 10:52:07 -0700 Subject: [PATCH] Remove deprecated context.awaitResult --- MigrationGuide_v1.0.md | 4 ++ Samples/SampleApp/Sources/DemoWorkflow.swift | 16 ++++---- .../Sources/Worker+Deprecated.swift | 41 ------------------- 3 files changed, 13 insertions(+), 48 deletions(-) delete mode 100644 WorkflowReactiveSwift/Sources/Worker+Deprecated.swift diff --git a/MigrationGuide_v1.0.md b/MigrationGuide_v1.0.md index 53f87a657..d167ca6d7 100644 --- a/MigrationGuide_v1.0.md +++ b/MigrationGuide_v1.0.md @@ -6,6 +6,10 @@ `SignalWorker` was deprecated in Workflow v1.0α and has been removed in the beta. See details in the alpha migration guide, [below](#signalworker-reactiveswiftsignal). +### Run `Worker` + +`context.awaitResult` was deprecated in Workflow v1.0α and has been removed in the beta. See details in the alpha migration guide, [below](#run-worker). + --- # Workflow v1.0α Migration Guide diff --git a/Samples/SampleApp/Sources/DemoWorkflow.swift b/Samples/SampleApp/Sources/DemoWorkflow.swift index b14159fb1..c508133ae 100644 --- a/Samples/SampleApp/Sources/DemoWorkflow.swift +++ b/Samples/SampleApp/Sources/DemoWorkflow.swift @@ -157,14 +157,16 @@ extension DemoWorkflow { refreshText = "Loading..." refreshEnabled = false - context.awaitResult(for: RefreshWorker()) { output -> Action in - switch output { - case .success(let result): - return .refreshComplete(result) - case .error(let error): - return .refreshError(error) + RefreshWorker() + .mapOutput { output -> Action in + switch output { + case .success(let result): + return .refreshComplete(result) + case .error(let error): + return .refreshError(error) + } } - } + .running(in: context) } let subscribeTitle: String diff --git a/WorkflowReactiveSwift/Sources/Worker+Deprecated.swift b/WorkflowReactiveSwift/Sources/Worker+Deprecated.swift deleted file mode 100644 index e4c8d3822..000000000 --- a/WorkflowReactiveSwift/Sources/Worker+Deprecated.swift +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Foundation -import Workflow - -extension RenderContext { - @available(*, deprecated, message: "Use `Worker().running(in:, outputMap:)` instead.") - public func awaitResult(for worker: W, outputMap: @escaping (W.Output) -> Action) where W: Worker, Action: WorkflowAction, WorkflowType == Action.WorkflowType { - worker - .mapOutput { outputMap($0) } - .running(in: self) - } - - @available(*, deprecated, message: "Use `Worker().running(in:)` instead.") - public func awaitResult(for worker: W) where W: Worker, W.Output: WorkflowAction, WorkflowType == W.Output.WorkflowType { - awaitResult(for: worker, outputMap: { $0 }) - } - - @available(*, deprecated, message: "Use `Worker().running(in:)` instead.") - public func awaitResult(for worker: W, onOutput: @escaping (W.Output, inout WorkflowType.State) -> WorkflowType.Output?) where W: Worker { - awaitResult(for: worker) { output in - AnyWorkflowAction { state in - onOutput(output, &state) - } - } - } -}