Alamofire 3 integration for ReactiveCocoa 4
Swift Ruby Objective-C
Latest commit 3408d6c Feb 15, 2017 @andrewprocter andrewprocter committed on GitHub Merge pull request #6 from envoy/swift-3
Swift 3 Migration

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'