Skip to content

Commit cb2ff35

Browse files
committed
debug swift concurrency
1 parent d8e2c1b commit cb2ff35

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

ICTMDBHomeModule/HomeInteractor.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ final class HomeInteractor: PresenterToInteractorHomeProtocol,@unchecked Sendabl
3636
do {
3737
let (popularResult, airingResult) = try await (popularMovies, airingMovies)
3838

39-
await MainActor.run {
40-
presenter?.sendPopularTvShows(popularResult.results)
41-
presenter?.sendAiringTvShows(airingResult.results)
42-
}
39+
await presenter?.sendPopularTvShows(popularResult.results)
40+
await presenter?.sendAiringTvShows(airingResult.results)
41+
4342
} catch {
44-
await MainActor.run {
45-
presenter?.sendError()
46-
}
43+
await presenter?.sendError()
44+
4745
}
4846
}
4947
}

ICTMDBHomeModule/HomePresenter.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import UIKit
1414
/// Handles the presentation logic for the Home module.
1515

1616
final class HomePresenter {
17-
17+
private var loadTask: Task<Void, Never>?
1818
// MARK: - Typealias
1919
/// Typealias for cell items displayed in collection view
2020
typealias CellItem = CellItemType
@@ -46,6 +46,10 @@ final class HomePresenter {
4646
self.interactor = interactor
4747
self.router = router
4848
}
49+
50+
deinit {
51+
loadTask?.cancel()
52+
}
4953
}
5054

5155

@@ -60,7 +64,7 @@ extension HomePresenter: ViewToPresenterHomeProtocol {
6064
view?.setBackColorAble(color: "backColor")
6165
view?.setNavigationTitle(title: LocalizableUI.homePageNavTitle.localized)
6266

63-
Task {
67+
loadTask = Task {
6468
await loadData()
6569
}
6670
}
@@ -73,6 +77,8 @@ extension HomePresenter: ViewToPresenterHomeProtocol {
7377
view?.finishLoading()
7478
}
7579

80+
81+
7682
}
7783

7884

0 commit comments

Comments
 (0)