Made the "fetch()" function for the FeedListViewController view controller in the Feed framework to use Swift concurrency.

This commit is contained in:
Javier Cicchelli 2024-03-22 15:15:16 +01:00
parent a1abe1f4ae
commit 8eec6f5666
2 changed files with 40 additions and 42 deletions

View File

@ -61,8 +61,7 @@ extension FeedListViewController {
}
// MARK: Functions
func fetch() {
Task {
func fetch() async {
isFilterEnabled = false
isLoading = items.isEmpty
@ -104,7 +103,6 @@ extension FeedListViewController {
isLoading = false
}
}
func filter(by option: FilterOption) {
guard option != filter else { return }

View File

@ -118,7 +118,7 @@ final class FeedListViewController: UIViewController {
registerTableCells()
bindViewModel()
viewModel.fetch()
Task { await viewModel.fetch() }
}
}
@ -170,7 +170,7 @@ private extension FeedListViewController {
// MARK: Actions
@objc func refresh(_ sender: AnyObject) {
self.viewModel.fetch()
Task { await self.viewModel.fetch() }
}
// MARK: Functions
@ -264,7 +264,7 @@ private extension FeedListViewController {
)
: nil,
action: isErrorState
? { self.viewModel.fetch() }
? { Task { await self.viewModel.fetch() } }
: nil
)