Skip to content

Commit 3bee87d

Browse files
authored
Merge pull request #18 from engingulek/feature/update-concurrency
update concurrency
2 parents 28b072b + 5e283ec commit 3bee87d

11 files changed

Lines changed: 43 additions & 44 deletions

.DS_Store

2 KB
Binary file not shown.

ICTMDBDetailModule/.DS_Store

6 KB
Binary file not shown.

ICTMDBDetailModule/DetailInteractor.swift

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import Foundation
88
import ICTMDBNetworkManagerKit
99

10-
final class TvShowDetailInteractor : @preconcurrency PresenterToInteractorTvShowDetailProtocol {
10+
final class TvShowDetailInteractor : PresenterToInteractorTvShowDetailProtocol {
11+
12+
1113

1214

1315
weak var presenter: (any InteractorToPresenterTvShowDetailProtocol)?
@@ -19,36 +21,29 @@ final class TvShowDetailInteractor : @preconcurrency PresenterToInteractorTvShow
1921
self.network = network
2022
}
2123
let deviceLanguageCode = Locale.current.language.languageCode ?? .english
22-
@MainActor func loadTvShowDetail(id: Int?) {
23-
guard let id = id else {return}
24-
let request = TvShowDetailRequest(
25-
language: deviceLanguageCode == .turkish ? .tr : .en,
26-
id: id)
27-
28-
network.execute(request) {[weak self] result in
29-
guard let self else {return}
30-
switch result {
31-
case .success(let data):
32-
presenter?.onHandle(handle: .sendData(data))
33-
34-
case .failure:
35-
presenter?.onHandle(handle: .sendError(.detailError))
36-
37-
}
24+
25+
26+
func loadTvShowDetail(id: Int?) async {
27+
do{
28+
guard let id = id else {return}
29+
let request = TvShowDetailRequest(
30+
language: deviceLanguageCode == .turkish ? .tr : .en,
31+
id: id)
32+
let result = try await network.execute(request)
33+
presenter?.onHandle(handle: .sendData(result))
34+
}catch{
35+
presenter?.onHandle(handle: .sendError(.detailError))
3836
}
3937
}
4038

41-
@MainActor func loadTvShowCasts(id: Int?) {
42-
guard let id = id else {return}
43-
let request = CastRequest(id: id)
44-
network.execute(request) { [weak self] result in
45-
guard let self else {return}
46-
switch result {
47-
case .success(let casts):
48-
presenter?.onHandle(handle: .sendCast(casts.cast))
49-
case .failure:
50-
presenter?.onHandle(handle: .sendError(.castError))
51-
}
39+
func loadTvShowCasts(id: Int?) async {
40+
do{
41+
guard let id = id else {return}
42+
let request = CastRequest(id: id)
43+
let result = try await network.execute(request)
44+
presenter?.onHandle(handle: .sendCast(result.cast))
45+
}catch{
46+
presenter?.onHandle(handle: .sendError(.castError))
5247
}
5348
}
5449
}

ICTMDBDetailModule/DetailPresenter.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ extension TvShowDetailPresenter: ViewToPresenterTvShowDetailProtocol {
5757

5858
func getID(id: Int?) {
5959
guard let id = id else {return}
60-
interactor.loadTvShowDetail(id: id)
61-
interactor.loadTvShowCasts(id: id)
60+
Task{@MainActor in
61+
await interactor.loadTvShowDetail(id: id)
62+
await interactor.loadTvShowCasts(id: id)
63+
}
64+
// interactor.loadTvShowDetail(id: id)
65+
// interactor.loadTvShowCasts(id: id)
6266

6367
}
6468

ICTMDBDetailModule/DetailProtocols.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ typealias Ables = UIViewAble & NavConUIAble
1010
import GenericCollectionViewKit
1111

1212

13-
13+
@MainActor
1414
protocol ViewToPresenterTvShowDetailProtocol:
1515
AnyObject, GenericCollectionDataSourceProtocol,
1616
GenericCollectionDelegateSourceProtocol,
@@ -28,11 +28,11 @@ protocol PresenterToViewTvShowDetailProtocol : AnyObject,Ables{
2828
func prepareCollectionView()
2929
}
3030

31-
31+
@MainActor
3232
protocol PresenterToInteractorTvShowDetailProtocol {
3333
var presenter: InteractorToPresenterTvShowDetailProtocol? {get set}
34-
func loadTvShowDetail(id:Int?)
35-
func loadTvShowCasts(id:Int?)
34+
func loadTvShowDetail(id:Int?) async
35+
func loadTvShowCasts(id:Int?) async
3636
}
3737

3838

ICTMDBDetailModule/ICTMDBDetailModule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010
import ICTMDBModularProtocols
1111
import ICTMDBNetworkManagerKit
1212

13-
public class ICTMDBDetailModule : @preconcurrency TvShowDetailProtocol {
13+
public class ICTMDBDetailModule : @MainActor TvShowDetailProtocol {
1414

1515

1616
public init() { }

ICTMDBDetailModule/cells/.DS_Store

6 KB
Binary file not shown.

ICTMDBDetailModule/request/CastRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ struct CastRequest : NetworkRequest {
1414
var path: NetworkPath {.casts(id)}
1515
var method: AlamofireMethod { .GET}
1616
var headers: [String : String]?
17-
var parameters: [String : Any]?
17+
var parameters: [String : Any]? { [:]}
1818
}

ICTMDBDetailModule/viewController/DetailViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ final class DetailViewController: UIViewController {
100100
}
101101
}
102102

103-
extension DetailViewController: @preconcurrency PresenterToViewTvShowDetailProtocol {
103+
extension DetailViewController: @MainActor PresenterToViewTvShowDetailProtocol {
104104
func sendData(detail: TvShowDetailPresentation, title: TvShowDetailTitlePresentation) {
105105
configureExampleData(detail, title)
106106
}

Package.resolved

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)