Skip to content

Commit 536bd27

Browse files
committed
Remove Combine/DispatchQueue helpers
1 parent 8b85942 commit 536bd27

3 files changed

Lines changed: 15 additions & 311 deletions

File tree

EssentialApp/EssentialApp.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
082C00042359E46C008927D3 /* XCTestCase+MemoryLeakTracking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082C00032359E46C008927D3 /* XCTestCase+MemoryLeakTracking.swift */; };
2525
082C00062359E4C6008927D3 /* SharedTestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082C00052359E4C6008927D3 /* SharedTestHelpers.swift */; };
2626
0832C9D0238D2811002314C9 /* SceneDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0832C9CF238D2811002314C9 /* SceneDelegateTests.swift */; };
27-
0835BF6D24850F9800A793D2 /* CombineHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0835BF6C24850F9800A793D2 /* CombineHelpers.swift */; };
2827
08367CD82486FB51009CD536 /* UIView+TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08367CD72486FB51009CD536 /* UIView+TestHelpers.swift */; };
2928
084BE5342EB38EC5006886E9 /* LoaderSpy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 084BE5332EB38EC5006886E9 /* LoaderSpy.swift */; };
3029
0851CDAC239AB13100C19B1D /* HTTPClientStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0851CDAB239AB13100C19B1D /* HTTPClientStub.swift */; };
@@ -83,7 +82,6 @@
8382
082C00032359E46C008927D3 /* XCTestCase+MemoryLeakTracking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+MemoryLeakTracking.swift"; sourceTree = "<group>"; };
8483
082C00052359E4C6008927D3 /* SharedTestHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedTestHelpers.swift; sourceTree = "<group>"; };
8584
0832C9CF238D2811002314C9 /* SceneDelegateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegateTests.swift; sourceTree = "<group>"; };
86-
0835BF6C24850F9800A793D2 /* CombineHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombineHelpers.swift; sourceTree = "<group>"; };
8785
08367CD72486FB51009CD536 /* UIView+TestHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+TestHelpers.swift"; sourceTree = "<group>"; };
8886
084BE5332EB38EC5006886E9 /* LoaderSpy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoaderSpy.swift; sourceTree = "<group>"; };
8987
0851CDAB239AB13100C19B1D /* HTTPClientStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPClientStub.swift; sourceTree = "<group>"; };
@@ -169,7 +167,6 @@
169167
children = (
170168
0895DA86234B3B950031BB2D /* AppDelegate.swift */,
171169
0895DA88234B3B950031BB2D /* SceneDelegate.swift */,
172-
0835BF6C24850F9800A793D2 /* CombineHelpers.swift */,
173170
08073B42238D2DF900A75DC6 /* FeedUIComposer.swift */,
174171
088B441B25309B6E00D75AAD /* CommentsUIComposer.swift */,
175172
08073B40238D2DF900A75DC6 /* WeakRefVirtualProxy.swift */,
@@ -315,7 +312,6 @@
315312
08073B48238D2DFA00A75DC6 /* WeakRefVirtualProxy.swift in Sources */,
316313
0895DA89234B3B950031BB2D /* SceneDelegate.swift in Sources */,
317314
08073B49238D2DFA00A75DC6 /* FeedViewAdapter.swift in Sources */,
318-
0835BF6D24850F9800A793D2 /* CombineHelpers.swift in Sources */,
319315
088B441C25309B6E00D75AAD /* CommentsUIComposer.swift in Sources */,
320316
);
321317
runOnlyForDeploymentPostprocessing = 0;

EssentialApp/EssentialApp/CombineHelpers.swift

Lines changed: 0 additions & 284 deletions
This file was deleted.

EssentialApp/EssentialApp/SceneDelegate.swift

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,7 @@ import EssentialFeed
99

1010
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1111
var window: UIWindow?
12-
13-
private lazy var scheduler: AnyDispatchQueueScheduler = {
14-
if let store = store as? CoreDataFeedStore {
15-
return .scheduler(for: store)
16-
}
1712

18-
return DispatchQueue(
19-
label: "com.essentialdeveloper.infra.queue",
20-
qos: .userInitiated
21-
).eraseToAnyScheduler()
22-
}()
23-
2413
private lazy var httpClient: HTTPClient = {
2514
URLSessionHTTPClient(session: URLSession(configuration: .ephemeral))
2615
}()
@@ -39,11 +28,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
3928
return InMemoryFeedStore()
4029
}
4130
}()
42-
43-
private lazy var localFeedLoader: LocalFeedLoader = {
44-
LocalFeedLoader(store: store, currentDate: Date.init)
45-
}()
46-
31+
4732
private lazy var baseURL = URL(string: "https://ile-api.essentialdeveloper.com/essential-feed")!
4833

4934
private lazy var navigationController = UINavigationController(
@@ -71,13 +56,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
7156
}
7257

7358
func sceneWillResignActive(_ scene: UIScene) {
74-
scheduler.schedule { [localFeedLoader, logger] in
75-
do {
76-
try localFeedLoader.validateCache()
77-
} catch {
78-
logger.error("Failed to validate cache with error: \(error.localizedDescription)")
79-
}
80-
}
59+
validateCache()
8160
}
8261

8362
private func showComments(for image: FeedImage) {
@@ -86,6 +65,19 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
8665
navigationController.pushViewController(comments, animated: true)
8766
}
8867

68+
private func validateCache() {
69+
Task.immediate { @MainActor in
70+
await store.schedule { [store, logger] in
71+
do {
72+
let localFeedLoader = LocalFeedLoader(store: store, currentDate: Date.init)
73+
try localFeedLoader.validateCache()
74+
} catch {
75+
logger.error("Failed to validate cache with error: \(error.localizedDescription)")
76+
}
77+
}
78+
}
79+
}
80+
8981
private func loadComments(url: URL) -> () async throws -> [ImageComment] {
9082
return { [httpClient] in
9183
let (data, response) = try await httpClient.get(from: url)

0 commit comments

Comments
 (0)