Latest 2.3.2
Homepage https://github.com/AvdLee/ALDataRequestView
License MIT
Platforms ios 8.0, tvos 9.0, requires ARC
Authors

Version
Language
License
Platform
Twitter

A simple way to show:

  • Loading view while a producer or observable is started
  • Reload view when a producer or observable is failed
  • Empty view when a producer or observable returns an empty array or an object which inherits the Emptyable protocol and isEmpty is true

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

ReactiveSwift & RxSwift

Simply call

attachTo(dataRequestView: dataRequestView)

on your signalProducer or observable.

Make sure you implement the ALDataRequestViewDataSource:

func loadingView(for dataRequestView: ALDataRequestView) -> UIView?
func reloadViewController(for dataRequestView: ALDataRequestView) -> ALDataReloadType?
func emptyView(for dataRequestView: ALDataRequestView) -> UIView?

Examples

RxSwift
let request = URLRequest(url: URL(string: "http://httpbin.org/status/400")!)
rxDisposable = URLSession.shared.rx.data(request: request).attachToDataRequestView(dataRequestView: dataRequestView!).subscribe()
ReactiveSwift
let request = URLRequest(url: URL(string: "http://httpbin.org/status/400")!)
dataSignalProducer = URLSession.shared
    .reactive.data(with: request)
    .flatMap(.latest, transform: { (data, response) -> SignalProducer<Data, NSError> in
        if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode > 299 {
            return SignalProducer(error: NSError(domain: "", code: httpResponse.statusCode, userInfo: nil))
        }
        return SignalProducer(value: data)
    })
    .attachTo(dataRequestView: dataRequestView!)

Installation

ALDataRequestView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "ALDataRequestView"

Swift version vs Pod version

Swift version Pod version
3.X >= 2.0.0
2.3 1.0.4

Author

Antoine van der Lee, info@avanderlee.com

License

ALDataRequestView is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ALDataRequestView",
    "version": "2.3.2",
    "summary": "A view representation for data requests. Support for ReactiveCocoa and RXSwift.",
    "description": "A view representation for data requests. Support for ReactiveCocoa and RXSwift by attached it to signalproducers and observables.",
    "homepage": "https://github.com/AvdLee/ALDataRequestView",
    "license": "MIT",
    "authors": {
        "Antoine van der Lee": "info@avanderlee.com"
    },
    "source": {
        "git": "https://github.com/AvdLee/ALDataRequestView.git",
        "tag": "2.3.2"
    },
    "social_media_url": "https://twitter.com/twannl",
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "default_subspecs": "Core",
    "pushed_with_swift_version": "3.0",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "Source/*.swift",
            "dependencies": {
                "PureLayout": [],
                "ReachabilitySwift": []
            },
            "frameworks": "Foundation"
        },
        {
            "name": "RxSwift",
            "source_files": "Source/RxSwift/*.swift",
            "dependencies": {
                "RxSwift": [],
                "RxCocoa": [],
                "ALDataRequestView/Core": []
            }
        },
        {
            "name": "ReactiveCocoa",
            "source_files": "Source/ReactiveCocoa/*.swift",
            "dependencies": {
                "ReactiveSwift": [],
                "ALDataRequestView/Core": []
            }
        }
    ]
}

Pin It on Pinterest

Share This