Giter VIP home page Giter VIP logo

loadingretry's Introduction

LoadingRetry

CI Status Version License Platform

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

  1. confirm to protocol LoadingRetryType. e.g.

    class ViewController: UIViewController, LoadingRetryType {
    
    }
  2. implement requirements of protocol LoadingRetryType, provide your loadingView and errorView viewControllerType.

    class ViewController: UIViewController, LoadingRetryType {
        lazy var loadingView: LoadingViewController = {
            return LoadingViewController()
        }()
    
        lazy var errorView: ErrorViewController = {
            return ErrorViewController()
        }()
    }
  3. call setLoadingView(visible: Bool) and setErrorView(visible: Bool) to control the display of loadingView and errorView.

    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.

loadingretry's People

Contributors

srv7 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.