Skip to content

Commit 1988e0a

Browse files
committed
debug for swift concurrency
1 parent cb2ff35 commit 1988e0a

3 files changed

Lines changed: 15 additions & 24 deletions

File tree

ICTMDBHomeModule/HomeInteractor.swift

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

39-
await presenter?.sendPopularTvShows(popularResult.results)
40-
await presenter?.sendAiringTvShows(airingResult.results)
41-
39+
await MainActor.run {
40+
presenter?.sendData(
41+
popular: popularResult.results,
42+
airingToday: airingResult.results)
43+
44+
}
4245
} catch {
43-
await presenter?.sendError()
44-
46+
await MainActor.run {
47+
presenter?.sendError()
48+
}
4549
}
4650
}
4751
}

ICTMDBHomeModule/HomePresenter.swift

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ extension HomePresenter {
200200
// MARK: - InteractorToPresenterHomeProtocol
201201
/// Receives data from the Interactor and updates the view.
202202
extension HomePresenter: InteractorToPresenterHomeProtocol {
203+
203204
func sendError() {
204205

205206
view?.sendError(errorState: (isHidden: true,
@@ -208,23 +209,14 @@ extension HomePresenter: InteractorToPresenterHomeProtocol {
208209

209210
}
210211

211-
212-
func sendAiringTvShows(_ data: [AiringToday]) {
213-
214-
airingTodayShows = data.map { AiringTodayPresentation(tvShow: $0) }
215-
view?.sendError(errorState: (isHidden: false, message: ""))
216-
view?.relaodCollectionView()
217-
218-
}
219-
220-
func sendPopularTvShows(_ data: [PopularTvShows]) {
221-
222-
popularTvShows = data
212+
func sendData(popular: [PopularTvShows], airingToday: [AiringToday]) {
213+
popularTvShows = popular
223214
.map { PopularTVShowPresentation(tvShow: $0) }
224215
.sorted { $0.rating > $1.rating }
216+
airingTodayShows = airingToday.map { AiringTodayPresentation(tvShow: $0) }
225217
view?.sendError(errorState: (isHidden: false, message: ""))
226218
view?.relaodCollectionView()
227-
228219
}
220+
229221
}
230222

ICTMDBHomeModule/HomeProtocols.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,9 @@ protocol PresenterToInteractorHomeProtocol:Sendable,AnyObject {
6363

6464
// MARK: - Interactor → Presenter
6565
/// Protocol for sending data or errors from Interactor to Presenter.
66-
@MainActor
6766
protocol InteractorToPresenterHomeProtocol : AnyObject{
6867

69-
/// Sends fetched popular TV shows
70-
func sendPopularTvShows(_ data: [PopularTvShows])
71-
72-
/// Sends fetched airing today TV shows
73-
func sendAiringTvShows(_ data: [AiringToday])
68+
func sendData(popular:[PopularTvShows],airingToday:[AiringToday])
7469

7570
/// Sends an error state
7671
func sendError()

0 commit comments

Comments
 (0)