ReactiveAFNetworking
ReactiveAFNetworking is an extension of AFNetworking 3 by adding reactive capability, inpired by AFNetworking-RACExtension which still use AFNetworking 2. This library is build on top of AFNetworking 3.0+ and ReactiveObjC, so if you want to use the same code interface as AFNetworking-RACExtension but need the latest version of AFNetworking and ReactiveObjC please feel free to use ReactiveAFNetworking.
Installation
ReactiveAFNetworking is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ReactiveAFNetworking'
If you want to use this library in swift project, it will be easier to use ReactiveCocoa 2.4.7 instead of ReactiveObjC. To support that requirement you can add the following line instead to your Podfile:
pod 'ReactiveAFNetworking', :git => 'https://github.com/ibnusina/ReactiveAFNetworking', :branch => 'swift-extensibility'
Usage
Request signals work in much the same way you would expect them to. Any request that is subscribed to is automatically enqueued and the results, be they errors or JSON, are sent back to you the subscriber. For example
AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];
RACSignal *signal = [sessionManager rac_GET:@"https://api.reddit.com/r/cat/hot" parameters:nil];
[signal subscribeNext:^(RACTuple *tuple) {
NSLog(@"response: %@, task: %@", tuple.second, tuple.first);
} error:^(NSError * error) {
NSLog(@"on error: %@", error);
}];
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
ReactiveAFNetworking support iOS 8.0+.
Author
Ibnu Sina: [email protected]
License
ReactiveAFNetworking is available under the MIT license. See the LICENSE file for more info.