mirror of
https://github.com/ReactiveX/RxSwift.git
synced 2024-10-05 14:37:29 +03:00
use new reachability service to handle network errors in AutoLoading example
This commit is contained in:
parent
a35c77c0e0
commit
5dfd604f29
@ -35,15 +35,6 @@ class GitHubSearchRepositoriesViewController: ViewController, UITableViewDelegat
|
||||
let tableView = self.tableView
|
||||
let searchBar = self.searchBar
|
||||
|
||||
// init reachability to check internet connection
|
||||
let reachability:Reachability?
|
||||
do{
|
||||
reachability = try Reachability.reachabilityForInternetConnection()
|
||||
}catch let error{
|
||||
print("cannot create reachability - \(error)")
|
||||
reachability = nil
|
||||
}
|
||||
|
||||
let allRepositories = repositories
|
||||
.map { repositories in
|
||||
return [SectionModel(model: "Repositories", items: repositories)]
|
||||
@ -83,14 +74,7 @@ class GitHubSearchRepositoriesViewController: ViewController, UITableViewDelegat
|
||||
} else {
|
||||
return GitHubSearchRepositoriesAPI.sharedAPI.search(query, loadNextPageTrigger: loadNextPageTrigger)
|
||||
.retry(3)
|
||||
.catchError{ (e) -> Observable<SearchRepositoryResponse> in
|
||||
reachability?
|
||||
.rx_reachable
|
||||
.skipWhile { $0 != .Reachable }
|
||||
.flatMap { _ in failWith(e)}
|
||||
?? failWith(e)
|
||||
}
|
||||
.retry()
|
||||
.retryOnBecomesReachable(.Repositories([]), reachabilityService: ReachabilityService.sharedReachabilityService)
|
||||
}
|
||||
}
|
||||
.switchLatest()
|
||||
|
Loading…
Reference in New Issue
Block a user