LoadingRetry
Example
To run the example project, clone the repo, and run pod install from the Example directory first.
Requirements
| iOS | 9.0+ |
|---|---|
| swift | 4.2+ |
Usage
-
confirm to protocol
LoadingRetryType. e.g.class ViewController: UIViewController, LoadingRetryType { }
-
implement requirements of protocol
LoadingRetryType, provide yourloadingViewanderrorViewviewControllerType.class ViewController: UIViewController, LoadingRetryType { lazy var loadingView: LoadingViewController = { return LoadingViewController() }() lazy var errorView: ErrorViewController = { return ErrorViewController() }() }
-
call
setLoadingView(visible: Bool)andsetErrorView(visible: Bool)to control the display ofloadingViewanderrorView.viewController.setLoadingView(visible: visible) viewController.setErrorView(visible: visible)
Installation
LoadingRetry is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LoadingRetry'Rx Support
pod 'LoadingRetry/RxSwift'LoadingRetry also add rx support. if you are using RxSwift, you can control the display of loadingView and errorView by using loadingViewVisible and errorViewVisible extension property of UIViewController.
viewModel.fetchDataAction.executing.bind(to: rx.loadingViewVisible).disposed(by: bag)
viewModel.fetchDataAction.executing
.filter { $0 }.map { !$0 }
.bind(to: rx.errorViewVisible)
.disposed(by: bag)
viewModel.fetchDataAction.errors
.map { _ in true }
.bind(to: rx.errorViewVisible)
.disposed(by: bag)Author
srv7, [email protected]
License
LoadingRetry is available under the MIT license. See the LICENSE file for more info.
