Skip to content

Commit 82c13b4

Browse files
committed
Checking task cancellation
1 parent 1b9a9c2 commit 82c13b4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

SkyWizardAPI/Sources/SkyWizardService/Geocoding/GeocodingServiceRemote.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public final class GeocodingServiceRemote: GeocodingService {
1919
}
2020

2121
public func geocode(with location: CLLocationCoordinate2D) async throws -> GeocodeData {
22+
23+
//Checking task cancellation
24+
try Task.checkCancellation()
25+
2226
let task = await dataTransferService.request(with: GeocodingEndpoints.getGeocoding(latitude: location.latitude, longitude: location.longitude))
2327
let value: GeocodeData = try await task.value.mapToGeocodeResult()
2428
return value

SkyWizardAPI/Sources/SkyWizardService/Weather/WeatherServiceRemote.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public final class WeatherServiceRemote: WeatherService {
1919
}
2020

2121
public func fetchWeather(for location: CLLocationCoordinate2D) async throws -> WeatherData {
22+
//Checking task cancellation
23+
try Task.checkCancellation()
24+
2225
let task = await dataTransferService.request(with: WeatherEndpoints.getWeather(latitude: location.latitude, longitude: location.longitude))
2326
return try await task.value
2427
}

0 commit comments

Comments
 (0)