CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

ReactiveAlamofire 3.0.0

ReactiveAlamofire 3.0.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2017
SwiftSwift Version 3.2
SPMSupports SPM

Maintained by Fabien Legoupillot, Becky Christensen, Robin Goos, Greg Lee.



 
Depends on:
ReactiveSwift~> 2.0
Alamofire~> 4.5
 

ReactiveAlamofire

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 CocoaPod

To install with CocoaPod, add ReactiveAlamofire to your Podfile:

pod 'ReactiveAlamofire', '~> 2.0.0'