Skip to content

Commit 1b9a9c2

Browse files
committed
Removed Task Wrapper
1 parent 33f9477 commit 1b9a9c2

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

SkyWizardAPI/Sources/SkyWizardService/Weather/WeatherService.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import SkyWizardEnum
1111
import SkyWizardModel
1212

1313
public protocol WeatherService {
14-
typealias TaskType = Task<WeatherData, Error>
15-
func fetchWeather(for location: CLLocationCoordinate2D) async throws -> TaskType
14+
func fetchWeather(for location: CLLocationCoordinate2D) async throws -> WeatherData
1615
func getWeatherType(for current: WeatherData.CurrentWeatherData) -> CurrentWeatherType
1716
func getWeather(for daily: WeatherData.DailyWeatherData) throws -> [DailyWeatherData]
1817
func getWeather(for hourly: WeatherData.HourlyWeatherData) throws -> [HourlyWeatherData]

SkyWizardAPI/Sources/SkyWizardService/Weather/WeatherServiceMock.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import SkyWizardModel
1212

1313
#if DEBUG
1414
public class WeatherServiceMock: WeatherService {
15-
public func fetchWeather(for location: CLLocationCoordinate2D) async throws -> TaskType {
16-
return Task {
17-
.sample
18-
}
15+
public func fetchWeather(for location: CLLocationCoordinate2D) async throws -> WeatherData {
16+
.sample
1917
}
2018

2119
public func getWeatherType(for current: WeatherData.CurrentWeatherData) -> CurrentWeatherType {

SkyWizardAPI/Sources/SkyWizardService/Weather/WeatherServiceRemote.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ public final class WeatherServiceRemote: WeatherService {
1818
self.dataTransferService = dataTransferService
1919
}
2020

21-
public func fetchWeather(for location: CLLocationCoordinate2D) async throws -> TaskType {
22-
await dataTransferService.request(with: WeatherEndpoints.getWeather(latitude: location.latitude, longitude: location.longitude))
21+
public func fetchWeather(for location: CLLocationCoordinate2D) async throws -> WeatherData {
22+
let task = await dataTransferService.request(with: WeatherEndpoints.getWeather(latitude: location.latitude, longitude: location.longitude))
23+
return try await task.value
2324
}
2425

2526
public func getWeatherType(for current: WeatherData.CurrentWeatherData) -> CurrentWeatherType {

0 commit comments

Comments
 (0)