基于AFNetworking(3.2.1)和ReactiveObjC的iOS网络请求封装

基于AFNetworking(3.2.1)和ReactiveObjC的iOS网络请求封装

参考了YTKNetwok的离散型网络请求框架的封装模式;
GitHub

1.网络状态检测

[[[AFNetworkReachabilityManager sharedManager] rac_startMonitoring] subscribeNext:^(id _Nullable x) {

      NSLog(@"%@", x);
    }];
 [[AFNetworkReachabilityManager sharedManager] stopMonitoring]; 

2.网络请求

[[self.request start] subscribeStart:^(NSURLSessionTask *task) {
      NSLog(@"start");
    }
        Next:^(EYRequest *_Nullable x) {
          NSLog(@"%@", x.responseObject);
        }
        progress:^(NSProgress *progress) {
          NSLog(@"progress:%f", progress.fractionCompleted);
        }
        error:^(NSError *_Nullable error) {
          NSLog(@"error:%@", error);
        }
        completed:^{
          NSLog(@"completed");
        }];
  1. 使用:

pod 'EYNetwork/Client'