Skip to content

Commit edb6f17

Browse files
committed
Rename ContainerViewController to WorkflowHostingController.
1 parent 07a8864 commit edb6f17

File tree

21 files changed

+70
-71
lines changed

21 files changed

+70
-71
lines changed

Samples/AsyncWorker/AsyncWorker/SceneDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1818
guard let windowScene = (scene as? UIWindowScene) else { return }
1919

2020
let window = UIWindow(windowScene: windowScene)
21-
window.rootViewController = ContainerViewController(workflow: AsyncWorkerWorkflow())
21+
window.rootViewController = WorkflowHostingController(workflow: AsyncWorkerWorkflow())
2222
self.window = window
2323
window.makeKeyAndVisible()
2424
}

Samples/SampleApp/Sources/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2424
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2525
window = UIWindow(frame: UIScreen.main.bounds)
2626

27-
window?.rootViewController = ContainerViewController(workflow: RootWorkflow())
27+
window?.rootViewController = WorkflowHostingController(workflow: RootWorkflow())
2828

2929
window?.makeKeyAndVisible()
3030

Samples/SplitScreenContainer/DemoApp/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2626
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2727
let window = UIWindow(frame: UIScreen.main.bounds)
2828

29-
let container = ContainerViewController(
29+
let container = WorkflowHostingController(
3030
workflow: DemoWorkflow()
3131
)
3232

Samples/TicTacToe/Sources/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2525
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2626
window = UIWindow(frame: UIScreen.main.bounds)
2727

28-
window?.rootViewController = ContainerViewController(workflow: MainWorkflow())
28+
window?.rootViewController = WorkflowHostingController(workflow: MainWorkflow())
2929

3030
window?.makeKeyAndVisible()
3131

Samples/Tutorial/AppHost/Sources/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2424
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2525
window = UIWindow(frame: UIScreen.main.bounds)
2626

27-
let viewController = TutorialContainerViewController()
27+
let viewController = TutorialHostingViewController()
2828

2929
window?.rootViewController = viewController
3030

Samples/Tutorial/Frameworks/Tutorial1Complete/Sources/TutorialContainerViewController.swift renamed to Samples/Tutorial/Frameworks/Tutorial1Complete/Sources/TutorialHostingViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import UIKit
1818
import Workflow
1919
import WorkflowUI
2020

21-
public final class TutorialContainerViewController: UIViewController {
21+
public final class TutorialHostingViewController: UIViewController {
2222
let containerViewController: UIViewController
2323

2424
public init() {
25-
// Create a `ContainerViewController` with the `WelcomeWorkflow` as the root workflow
26-
self.containerViewController = ContainerViewController(workflow: WelcomeWorkflow())
25+
// Create a `WorkflowHostingController` with the `WelcomeWorkflow` as the root workflow
26+
self.containerViewController = WorkflowHostingController(workflow: WelcomeWorkflow())
2727

2828
super.init(nibName: nil, bundle: nil)
2929
}

Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/TutorialContainerViewController.swift renamed to Samples/Tutorial/Frameworks/Tutorial2Complete/Sources/TutorialHostingViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import UIKit
1919
import Workflow
2020
import WorkflowUI
2121

22-
public final class TutorialContainerViewController: UIViewController {
22+
public final class TutorialHostingViewController: UIViewController {
2323
let containerViewController: UIViewController
2424

2525
public init() {
26-
// Create a `ContainerViewController` with the `RootWorkflow` as the root workflow
27-
self.containerViewController = ContainerViewController(workflow: RootWorkflow())
26+
// Create a `WorkflowHostingController` with the `RootWorkflow` as the root workflow
27+
self.containerViewController = WorkflowHostingController(workflow: RootWorkflow())
2828

2929
super.init(nibName: nil, bundle: nil)
3030
}

Samples/Tutorial/Frameworks/Tutorial2Complete/Sources/TutorialContainerViewController.swift renamed to Samples/Tutorial/Frameworks/Tutorial3Complete/Sources/TutorialHostingViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import UIKit
1919
import Workflow
2020
import WorkflowUI
2121

22-
public final class TutorialContainerViewController: UIViewController {
22+
public final class TutorialHostingViewController: UIViewController {
2323
let containerViewController: UIViewController
2424

2525
public init() {
26-
// Create a `ContainerViewController` with the `RootWorkflow` as the root workflow
27-
self.containerViewController = ContainerViewController(workflow: RootWorkflow())
26+
// Create a `WorkflowHostingController` with the `RootWorkflow` as the root workflow
27+
self.containerViewController = WorkflowHostingController(workflow: RootWorkflow())
2828

2929
super.init(nibName: nil, bundle: nil)
3030
}

Samples/Tutorial/Frameworks/Tutorial3Complete/Sources/TutorialContainerViewController.swift renamed to Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/TutorialHostingViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import UIKit
1919
import Workflow
2020
import WorkflowUI
2121

22-
public final class TutorialContainerViewController: UIViewController {
22+
public final class TutorialHostingViewController: UIViewController {
2323
let containerViewController: UIViewController
2424

2525
public init() {
26-
// Create a `ContainerViewController` with the `RootWorkflow` as the root workflow
27-
self.containerViewController = ContainerViewController(workflow: RootWorkflow())
26+
// Create a `WorkflowHostingController` with the `RootWorkflow` as the root workflow
27+
self.containerViewController = WorkflowHostingController(workflow: RootWorkflow())
2828

2929
super.init(nibName: nil, bundle: nil)
3030
}

Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/TutorialContainerViewController.swift renamed to Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/TutorialHostingViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import UIKit
1919
import Workflow
2020
import WorkflowUI
2121

22-
public final class TutorialContainerViewController: UIViewController {
22+
public final class TutorialHostingViewController: UIViewController {
2323
let containerViewController: UIViewController
2424

2525
public init() {
26-
// Create a `ContainerViewController` with the `RootWorkflow` as the root workflow
27-
self.containerViewController = ContainerViewController(workflow: RootWorkflow())
26+
// Create a `WorkflowHostingController` with the `RootWorkflow` as the root workflow
27+
self.containerViewController = WorkflowHostingController(workflow: RootWorkflow())
2828

2929
super.init(nibName: nil, bundle: nil)
3030
}

Samples/Tutorial/Frameworks/TutorialBase/Sources/TutorialContainerViewController.swift renamed to Samples/Tutorial/Frameworks/TutorialBase/Sources/TutorialHostingViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import UIKit
1818
import Workflow
1919
import WorkflowUI
2020

21-
public final class TutorialContainerViewController: UIViewController {
21+
public final class TutorialHostingViewController: UIViewController {
2222
let containerViewController: UIViewController
2323

2424
public init() {

Samples/Tutorial/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Nearly all of the code is in the `Frameworks` directory.
1313
To help with the setup, we have created a few helpers:
1414
- `TutorialViews`: A set of 3 views for the 3 screens we will be building, `Welcome`, `TodoList`, and `TodoEdit`.
1515
- `TutorialBase`: This is the starting point to build out the tutorial. It contains view controllers that host the views from `TutorialViews` to see how they display.
16-
- Additionally, there is a `TutorialContainerViewController` that the AppDelegate sets as the root view controller. This will be our launching point for all of our workflows.
16+
- Additionally, there is a `TutorialHostingViewController` that the AppDelegate sets as the root view controller. This will be our launching point for all of our workflows.
1717
- `TutorialFinal`: This is an example of the completed tutorial - could be used as a reference if you get stuck.
1818

1919
## Getting started

Samples/Tutorial/Tutorial.xcodeproj/xcshareddata/xcschemes/Tutorial.xcscheme

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<MacroExpansion>
31+
<BuildableReference
32+
BuildableIdentifier = "primary"
33+
BlueprintIdentifier = "E85390A62314AF2D001B6313"
34+
BuildableName = "Tutorial.app"
35+
BlueprintName = "Tutorial"
36+
ReferencedContainer = "container:Tutorial.xcodeproj">
37+
</BuildableReference>
38+
</MacroExpansion>
3039
<Testables>
3140
<TestableReference
3241
skipped = "NO">
@@ -69,17 +78,6 @@
6978
</BuildableReference>
7079
</TestableReference>
7180
</Testables>
72-
<MacroExpansion>
73-
<BuildableReference
74-
BuildableIdentifier = "primary"
75-
BlueprintIdentifier = "E85390A62314AF2D001B6313"
76-
BuildableName = "Tutorial.app"
77-
BlueprintName = "Tutorial"
78-
ReferencedContainer = "container:Tutorial.xcodeproj">
79-
</BuildableReference>
80-
</MacroExpansion>
81-
<AdditionalOptions>
82-
</AdditionalOptions>
8381
</TestAction>
8482
<LaunchAction
8583
buildConfiguration = "Debug"
@@ -101,8 +99,6 @@
10199
ReferencedContainer = "container:Tutorial.xcodeproj">
102100
</BuildableReference>
103101
</BuildableProductRunnable>
104-
<AdditionalOptions>
105-
</AdditionalOptions>
106102
</LaunchAction>
107103
<ProfileAction
108104
buildConfiguration = "Release"

Samples/Tutorial/Tutorial1.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,32 +125,32 @@ extension WelcomeWorkflow {
125125
}
126126
```
127127

128-
### Setting up the ContainerViewController
128+
### Setting up the WorkflowHostingController
129129

130130
Now we have our `WelcomeWorkflow` rendering a `WelcomeScreen`, and have a view controller that knows how to display with a `WelcomeScreen`. It's time to bind this all together and actually show it on the screen!
131131

132-
We'll update the `TutorialContainerViewController` to hold a child *ContainerViewController* that will host our workflow:
132+
We'll update the `TutorialContainerViewController` to hold a child *WorkflowHostingController* that will host our workflow:
133133

134134
```swift
135135
import UIKit
136136
import Workflow
137137
import WorkflowUI
138138

139139

140-
public final class TutorialContainerViewController: UIViewController {
140+
public final class TutorialHostingViewController: UIViewController {
141141
let containerViewController: UIViewController
142142

143143
public init() {
144-
// Create a `ContainerViewController` with the `WelcomeWorkflow` as the root workflow.
145-
containerViewController = ContainerViewController(
144+
// Create a `WorkflowHostingController` with the `WelcomeWorkflow` as the root workflow.
145+
containerViewController = WorkflowHostingController(
146146
workflow: WelcomeWorkflow()
147147
)
148148

149149
super.init(nibName: nil, bundle: nil)
150150
}
151151
```
152152

153-
Now, we've created our `ContainerViewController` with the `WelcomeWorkflow` as the root.
153+
Now, we've created our `WorkflowHostingController` with the `WelcomeWorkflow` as the root.
154154

155155
We can finally run the app again! It will look exactly the same as before, but now it is powered by our workflow.
156156

@@ -294,7 +294,7 @@ Here is what is happening on each keypress:
294294

295295
# Summary
296296

297-
In this tutorial, we covered creating a Screen, ScreenViewController, Workflow, and binding them together in a ContainerViewController. We also covered the Workflow being responsible for the state of the UI instead of the view controller being responsible.
297+
In this tutorial, we covered creating a Screen, ScreenViewController, Workflow, and binding them together in a `WorkflowHostingController`. We also covered the Workflow being responsible for the state of the UI instead of the view controller being responsible.
298298

299299
Next, we will create a second screen and workflow, and the use composition to navigate between them.
300300

Samples/Tutorial/Tutorial2.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Start from the implementation of `Tutorial1` if you're skipping ahead. You can d
1212

1313
## Second Workflow
1414

15-
Let's add a second screen and workflow so we have somewhere to land after we log in. Our next screen will be a list of "todo" items, as todo apps are the best apps. To see an example, modify the `TutorialContainerViewController` to show the `TodoListSampleViewController`. Once you're done looking around, the `TodoListSampleViewController` can be removed, as we will be replacing it with a screen and workflow.
15+
Let's add a second screen and workflow so we have somewhere to land after we log in. Our next screen will be a list of "todo" items, as todo apps are the best apps. To see an example, modify the `TutorialHostingViewController` to show the `TodoListSampleViewController`. Once you're done looking around, the `TodoListSampleViewController` can be removed, as we will be replacing it with a screen and workflow.
1616

1717
Create a new Screen/ViewController pair called `TodoList`:
1818

@@ -93,19 +93,19 @@ extension TodoListWorkflow {
9393

9494
### Showing the new screen and workflow
9595

96-
For now, let's just show this new screen instead of the login screen/workflow. Update the `TutorialContainerViewController` to show the `TodoListWorkflow`:
96+
For now, let's just show this new screen instead of the login screen/workflow. Update the `TutorialHostingViewController` to show the `TodoListWorkflow`:
9797

9898
```swift
99-
public final class TutorialContainerViewController: UIViewController {
99+
public final class TutorialHostingViewController: UIViewController {
100100
let containerViewController: UIViewController
101101

102102
public init() {
103-
// Create a `ContainerViewController` with the `WelcomeWorkflow` as the root workflow.
104-
// containerViewController = ContainerViewController(
103+
// Create a `WorkflowHostingController` with the `WelcomeWorkflow` as the root workflow.
104+
// containerViewController = WorkflowHostingController(
105105
// workflow: WelcomeWorkflow()
106106
// )
107107
// Show the TodoList Workflow instead:
108-
containerViewController = ContainerViewController(
108+
containerViewController = WorkflowHostingController(
109109
workflow: TodoListWorkflow()
110110
)
111111

@@ -233,17 +233,17 @@ struct WelcomeWorkflow: Workflow {
233233
}
234234
```
235235

236-
Update the `TutorialContainerViewController` to start at the `RootWorkflow` and we'll see the welcome screen again:
236+
Update the `TutorialHostingViewController` to start at the `RootWorkflow` and we'll see the welcome screen again:
237237

238238
```swift
239-
public final class TutorialContainerViewController: UIViewController {
239+
public final class TutorialHostingViewController: UIViewController {
240240
let containerViewController: UIViewController
241241

242242
public init() {
243243
// ...
244244

245-
// Create a `ContainerViewController` with the `RootWorkflow` as the root workflow.
246-
containerViewController = ContainerViewController(
245+
// Create a `WorkflowHostingController` with the `RootWorkflow` as the root workflow.
246+
containerViewController = WorkflowHostingController(
247247
workflow: RootWorkflow()
248248
)
249249

Samples/Tutorial/Tutorial5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ class TodoWorkflowTests: XCTestCase {
652652

653653
The `RenderTester` allows easy "mocking" of child workflows and workers. However, this means that we are not exercising the full infrastructure (even though we could get a fairly high confidence from the tests). Sometimes, it may be worth putting together integration tests that test a full tree of Workflows.
654654

655-
Add another test to `RootWorkflowTests`. We will run the tree of workflows in a `WorkflowHost`, which is what the infrastructure uses for a `ContainerViewController`. This will be a "black box" test, as we can only test the behaviors from the rendering and will not be able to inspect the underlying states. This may be a useful test for validation when refactoring a tree of workflows to ensure they behave the same way.
655+
Add another test to `RootWorkflowTests`. We will run the tree of workflows in a `WorkflowHost`, which is what the infrastructure uses for a `WorkflowHostingController`. This will be a "black box" test, as we can only test the behaviors from the rendering and will not be able to inspect the underlying states. This may be a useful test for validation when refactoring a tree of workflows to ensure they behave the same way.
656656

657657
```swift
658658
// RootWorkflowTests.swift

Samples/WorkflowCombineSampleApp/WorkflowCombineSampleApp/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414

1515
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1616
window = UIWindow(frame: UIScreen.main.bounds)
17-
window?.rootViewController = ContainerViewController(workflow: DemoWorkflow())
17+
window?.rootViewController = WorkflowHostingController(workflow: DemoWorkflow())
1818
window?.makeKeyAndVisible()
1919

2020
return true

WorkflowUI/Sources/Container/ContainerViewController.swift renamed to WorkflowUI/Sources/Hosting/WorkflowHostingController.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import Workflow
2222

2323
/// Drives view controllers from a root Workflow.
24-
public final class ContainerViewController<ScreenType, Output>: UIViewController where ScreenType: Screen {
24+
public final class WorkflowHostingController<ScreenType, Output>: UIViewController where ScreenType: Screen {
2525
/// Emits output events from the bound workflow.
2626
public var output: Signal<Output, Never> {
2727
return workflowHost.output
@@ -145,7 +145,7 @@
145145
}
146146

147147
/// Wrapper around an AnyWorkflow that allows us to have a concrete
148-
/// WorkflowHost without ContainerViewController itself being generic
148+
/// WorkflowHost without WorkflowHostingController itself being generic
149149
/// around a Workflow.
150150
fileprivate struct RootWorkflow<Rendering, Output>: Workflow {
151151
typealias State = Void
@@ -165,4 +165,7 @@
165165
}
166166
}
167167

168+
@available(*, deprecated, renamed: "WorkflowHostingController")
169+
public typealias ContainerViewController = WorkflowHostingController
170+
168171
#endif

WorkflowUI/Sources/Screen/ViewEnvironment/ViewEnvironment.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/// appearing in).
2424
public struct ViewEnvironment {
2525
/// An empty view environment. This should only be used when setting up a
26-
/// root workflow into a root ContainerViewController or when writing tests.
26+
/// root workflow into a root WorkflowHostingController or when writing tests.
2727
/// In other scenarios, containers should pass down the ViewEnvironment
2828
/// value they get from above.
2929
public static let empty: ViewEnvironment = ViewEnvironment()

0 commit comments

Comments
 (0)