OfflineRequest
protocol OfflineRequest : AnyObject, DictionaryRepresentable
Protocol for objects enqueued in OfflineRequestManager to perform operations
-
Called whenever the request manager instructs the object to perform its network request
Declaration
Swift
func perform(completion: @escaping (Error?) -> Swift.Void)
Parameters
completion
completion fired when done, either with an Error or nothing in the case of success
-
shouldAttemptResubmission(forError:)
Default implementationAllows the OfflineRequest object to recover from an error if desired Only called if the error is not network related
Default Implementation
Declaration
Swift
func shouldAttemptResubmission(forError error: Error) -> Bool
Parameters
error
Should be equal to what was passed back in the perform(completion:) call
Return Value
Bool indicating whether perform(completion:) should be called again or the request should be dropped
-
Description for Network Status tab
Declaration
Swift
var title: String { get }
-
Information for Network Status tab
Declaration
Swift
var subtitle: String { get set }
-
Number of times request has failed
Declaration
Swift
var failures: Int { get }
-
save()
Extension methodPrompts the OfflineRequestManager to save to disk Used to persist any data changes over the course of a request if needed
Declaration
Swift
func save()
-
sendHeartbeat()
Extension methodResets the timeout on the request; Useful for long requests that have multiple steps
Declaration
Swift
func sendHeartbeat()
-
updateProgress(to:)
Extension methodProvides the current progress (0 to 1) on the ongoing request
Declaration
Swift
func updateProgress(to progress: Double)
Parameters
progress
current request progress