Alamofire 3 integration for ReactiveCocoa 4
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ReactiveAlamofire.xcodeproj
ReactiveAlamofire.xcworkspace
ReactiveAlamofire
ReactiveAlamofireTests
.gitignore
.swift-version
.travis.yml
Cartfile
Cartfile.resolved
LICENSE
README.md
ReactiveAlamofire.podspec

README.md

ReactiveAlamofire

Build Status Carthage compatible GitHub license

Alamofire 4 integration for ReactiveSwift

Example

import Alamofire
import ReactiveSwift
import ReactiveAlamofire
import Result

SignalProducer<DataRequest, NoError>.attempt {
    return .success(Alamofire.request("http://httpbin.org/get?foo=bar"))
}
    .responseProducer()  // Make the Request SignalProducer to be a Response SignalProducer
    .parseResponse(DataRequest.jsonResponseSerializer()) // Parse response with JSONResponseSerializer
    .startWithResult { result in
        switch result {
        case .failure(let error):
            print("failed, error=\(error)")
        case .success(let resp):
            print(resp.result.value ?? "No data")
        }
    }

here comes the output

{
    args =     {
        foo = bar;
    };
    headers =     {
        Accept = "*/*";
        "Accept-Encoding" = "gzip;q=1.0, compress;q=0.5";
        "Accept-Language" = "en-US;q=1.0";
        Host = "httpbin.org";
        "User-Agent" = "Unknown/Unknown (Unknown; OS Version 9.3 (Build 13E5181d))";
    };
    origin = "111.111.111.111";
    url = "http://httpbin.org/get?foo=bar";
}

voilà!

You can call responseProducer(responseSerializer: ResponseSerializerType) with any ResponseSerializer for Alamofire to parse the response.

Install with Carthage

To install with Carthage, add ReactiveAlamofire to your Cartfile:

github "envoy/ReactiveAlamofire"

Install with CocoaPod

To install with CocoaPod, add ReactiveAlamofire to your Podfile:

pod 'ReactiveAlamofire', '~> 2.0.0'