FWBatchRequest


@interface FWBatchRequest : NSObject

FWBatchRequest can be used to batch several FWRequest. Note that when used inside FWBatchRequest, a single FWRequest will have its own callback and delegate cleared, in favor of the batch request callback.

  • All the requests are stored in this array.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSArray<FWRequest *> *_Nonnull requestArray;
  • The delegate object of the batch request. Default is nil.

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) id<FWBatchRequestDelegate> delegate;
  • The success callback. Note this will be called only if all the requests are finished. This block will be called on the main queue.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) void (^) (FWBatchRequest *_Nonnull __strong) successCompletionBlock;
  • The failure callback. Note this will be called if one of the requests fails. This block will be called on the main queue.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) void (^) (FWBatchRequest *_Nonnull __strong) failureCompletionBlock;
  • tag

    Tag can be used to identify batch request. Default value is 0.

    Declaration

    Objective-C

    @property (nonatomic) NSInteger tag;
  • This can be used to add several accessories object. Note if you use addAccessory to add accessory this array will be automatically created. Default is nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSMutableArray<id<FWRequestAccessory>> *requestAccessories;
  • The first request that failed (and causing the batch request to fail).

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) FWRequest *failedRequest;
  • The requests that failed (and causing the batch request to fail).

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSArray<FWRequest *> *_Nonnull failedRequestArray;
  • When true, the batch request is stopped if one of the requests fails. Defaults to YES.

    Declaration

    Objective-C

    @property (nonatomic) BOOL stoppedOnFailure;
  • Creates a FWBatchRequest with a bunch of requests.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithRequestArray:
        (nonnull NSArray<FWRequest *> *)requestArray;

    Parameters

    requestArray

    requests useds to create batch request.

  • Set completion callbacks

    Declaration

    Objective-C

    - (void)setCompletionBlockWithSuccess:
                (nullable void (^)(FWBatchRequest *_Nonnull __strong))success
                                  failure:(nullable void (^)(
                                              FWBatchRequest *_Nonnull __strong))
                                              failure;
  • Nil out both success and failure callback blocks.

    Declaration

    Objective-C

    - (void)clearCompletionBlock;
  • Convenience method to add request accessory. See also requestAccessories.

    Declaration

    Objective-C

    - (void)addAccessory:(nonnull id<FWRequestAccessory>)accessory;
  • Append all the requests to queue.

    Declaration

    Objective-C

    - (void)start;
  • Stop all the requests of the batch request.

    Declaration

    Objective-C

    - (void)stop;
  • Convenience method to start the batch request with block callbacks.

    Declaration

    Objective-C

    - (void)startWithCompletionBlockWithSuccess:
                (nullable void (^)(FWBatchRequest *_Nonnull __strong))success
                                        failure:
                                            (nullable void (^)(
                                                FWBatchRequest *_Nonnull __strong))
                                                failure;
  • Convenience method to start the batch request with completion block.

    Declaration

    Objective-C

    - (void)startWithCompletion:
        (nullable void (^)(FWBatchRequest *_Nonnull __strong))completion;
  • Undocumented

    Declaration

    Objective-C

    - (void)startSynchronouslyWithSuccess:(nullable void (^)(FWBatchRequest *batchRequest))success failure:(nullable void (^)(FWBatchRequest *batchRequest))failure;
  • Undocumented

    Declaration

    Objective-C

    - (void)startSynchronouslyWithFilter:(nullable BOOL (^)(void))filter completion:(nullable void (^)(FWBatchRequest *batchRequest))completion;
  • Whether all response data is from local cache.

    Declaration

    Objective-C

    - (BOOL)isDataFromCache;

RequestAccessory

FWRequestAccessory

  • Undocumented

    Declaration

    Objective-C

    - (void)startWithWillStart:(nullable void (^)(FWBatchRequest *batchRequest))willStart
                      willStop:(nullable void (^)(FWBatchRequest *batchRequest))willStop
                       success:(nullable void (^)(FWBatchRequest *batchRequest))success
                       failure:(nullable void (^)(FWBatchRequest *batchRequest))failure
                       didStop:(nullable void (^)(FWBatchRequest *batchRequest))didStop;