Skip to content

Instantly share code, notes, and snippets.

@aalemi97
Last active October 14, 2020 10:09
Show Gist options
  • Save aalemi97/e5ec0294c5d79a5dbf6504e64e6f52e9 to your computer and use it in GitHub Desktop.
Save aalemi97/e5ec0294c5d79a5dbf6504e64e6f52e9 to your computer and use it in GitHub Desktop.
func retry(_ request: Request, for session: Session, dueTo error: Error,
completion: @escaping (RetryResult) -> Void) {
guard request.retryCount < retryLimit else {
completion(.doNotRetry)
return
}
print("\nretried; retry count: \(request.retryCount)\n")
refreshToken { isSuccess in
isSuccess ? completion(.retry) : completion(.doNotRetry)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment