Skip to content

Commit

Permalink
๐Ÿ’ŠFIX: ๋Ÿฐ์น˜๊ฐ€ ๋๋‚œ ํ›„์— ๋ฐ์ดํ„ฐ๊ฐ€ ๋„์ฐฉํ•ด์„œ ๊ธฐ์กด Country ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์—†๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ #25
Browse files Browse the repository at this point in the history
  • Loading branch information
yeahg-dev committed Feb 14, 2023
1 parent a820602 commit 37d4c14
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Moon Yeji on 2023/01/25.
//

import Combine
import UIKit

final class SearchCoordinator: NSObject, Coordinator {
Expand All @@ -17,14 +18,18 @@ final class SearchCoordinator: NSObject, Coordinator {
}

func start() {
let searchKeywordRepository = RealmSearchKeywordRepository()
let appSearchUseacase = AppSearchUsecase(
searchKeywordRepository: searchKeywordRepository)
let seachViewModel = SearchViewModel(appSearchUsecase: appSearchUseacase)
let searchVC = SearchViewController(searchViewModel: seachViewModel)
searchVC.coordinator = self

navigationController.pushViewController(searchVC, animated: false)
Task {
await AppSearchingConfiguration().downloadCountryCode()
await MainActor.run {
let searchKeywordRepository = RealmSearchKeywordRepository()
let appSearchUseacase = AppSearchUsecase(
searchKeywordRepository: searchKeywordRepository)
let seachViewModel = SearchViewModel(appSearchUsecase: appSearchUseacase)
let searchVC = SearchViewController(searchViewModel: seachViewModel)
searchVC.coordinator = self
navigationController.pushViewController(searchVC, animated: false)
}
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ struct AppSearchingConfiguration {
defaults.set(bool, forKey: UserDefaultsKey.isActiveSavingSearchKeyword)
}

func downloadCountryCode() async {
guard Country.list.isEmpty else {
return
}
do {
let countryCodes = try await CountryCodeAPIService().requestAllCountryCode()
Country.list += countryCodes.compactMap {$0.toDomain()}
} catch {
print("CountryCodeAPIService ์‹คํŒจ")
return
}
}
}

extension AppSearchingConfiguration {
Expand Down

0 comments on commit 37d4c14

Please sign in to comment.