@@ -230,12 +230,14 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
230230 /// - timeout: optional timeout. If no location were found before timeout a `LocationError.timeout` error is reported.
231231 /// - success: success handler to call when a new location were found for this request
232232 /// - error: error handler to call when an error did occour while searching for request
233+ /// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
233234 /// - Returns: request
234235 @discardableResult
235- public func getLocation( accuracy: Accuracy , frequency: Frequency , timeout: TimeInterval ? = nil , success: @escaping LocObserver . onSuccess , error: @escaping LocObserver . onError ) -> LocationRequest {
236+ public func getLocation( accuracy: Accuracy , frequency: Frequency , timeout: TimeInterval ? = nil , cancelOnError : Bool = false , success: @escaping LocObserver . onSuccess , error: @escaping LocObserver . onError ) -> LocationRequest {
236237
237238 let req = LocationRequest ( accuracy: accuracy, frequency: frequency, success, error)
238239 req. timeout = timeout
240+ req. cancelOnError = cancelOnError
239241 req. resume ( )
240242 return req
241243 }
@@ -250,15 +252,16 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
250252 /// specific geographical area, which is typically the user’s current location.
251253 /// - timeout: timeout of the operation; nil to ignore timeout, a valid seconds interval. If reverse geocoding does not succeded or
252254 /// fail inside this time interval request fails with `LocationError.timeout` error and registered callbacks are called.
255+ /// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
253256 ///
254257 /// - success: success handler to call when reverse geocoding succeded
255258 /// - failure: failure handler to call when reverse geocoding fails
256259 /// - Returns: request
257260 @discardableResult
258- public func getLocation( forAddress address: String , inRegion region: CLRegion ? = nil , timeout: TimeInterval ? = nil ,
259- success: @escaping GeocoderObserver . onSuccess , failure: @escaping GeocoderObserver . onError ) -> GeocoderRequest {
261+ public func getLocation( forAddress address: String , inRegion region: CLRegion ? = nil , timeout: TimeInterval ? = nil , cancelOnError: Bool = false , success: @escaping GeocoderObserver . onSuccess , failure: @escaping GeocoderObserver . onError ) -> GeocoderRequest {
260262 let req = GeocoderRequest ( address: address, region: region, success, failure)
261263 req. timeout = timeout
264+ req. cancelOnError = cancelOnError
262265 req. resume ( )
263266 return req
264267 }
@@ -307,14 +310,16 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
307310 ///
308311 /// - Parameters:
309312 /// - filter: The minimum angular change (measured in degrees) required to generate new heading events.
313+ /// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
310314 /// - success: succss handler
311315 /// - failure: failure handler
312316 /// - Returns: request
313317 @discardableResult
314- public func getContinousHeading( filter: CLLocationDegrees ,
315- success: @escaping HeadingObserver . onSuccess , failure: @escaping HeadingObserver . onError ) throws -> HeadingRequest {
318+ public func getContinousHeading( filter: CLLocationDegrees , cancelOnError : Bool = false ,
319+ success: @escaping HeadingObserver . onSuccess , failure: @escaping HeadingObserver . onError ) throws -> HeadingRequest {
316320 let request = try HeadingRequest ( filter: filter, success: success, failure: failure)
317321 request. resume ( )
322+ request. cancelOnError = cancelOnError
318323 return request
319324 }
320325
@@ -326,16 +331,18 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
326331 /// - Parameters:
327332 /// - center: coordinate center
328333 /// - radius: radius in meters
334+ /// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
329335 /// - enter: callback for region enter event
330336 /// - exit: callback for region exit event
331337 /// - error: callback for errors
332338 /// - Returns: request
333339 /// - Throws: throw `LocationError.serviceNotAvailable` if hardware does not support region monitoring
334340 @discardableResult
335- public func monitor( regionAt center: CLLocationCoordinate2D , radius: CLLocationDistance ,
341+ public func monitor( regionAt center: CLLocationCoordinate2D , radius: CLLocationDistance , cancelOnError : Bool = false ,
336342 enter: RegionObserver . onEvent ? , exit: RegionObserver . onEvent ? , error: @escaping RegionObserver . onFailure ) throws -> RegionRequest {
337343 let request = try RegionRequest ( center: center, radius: radius, onEnter: enter, onExit: exit, error: error)
338344 request. resume ( )
345+ request. cancelOnError = cancelOnError
339346 return request
340347 }
341348
@@ -344,15 +351,17 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
344351 ///
345352 /// - Parameters:
346353 /// - region: region to monitor
354+ /// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
347355 /// - enter: callback for region enter event
348356 /// - exit: callback for region exit event
349357 /// - error: callback for errors
350358 /// - error: callback for errors
351359 /// - Throws: throw `LocationError.serviceNotAvailable` if hardware does not support region monitoring
352360 @discardableResult
353- public func monitor( region: CLCircularRegion ,
361+ public func monitor( region: CLCircularRegion , cancelOnError : Bool = false ,
354362 enter: RegionObserver . onEvent ? , exit: RegionObserver . onEvent ? , error: @escaping RegionObserver . onFailure ) throws -> RegionRequest {
355363 let request = try RegionRequest ( region: region, onEnter: enter, onExit: exit, error: error)
364+ request. cancelOnError = cancelOnError
356365 request. resume ( )
357366 return request
358367 }
0 commit comments