FWChainRequest
@interface FWChainRequest : NSObject
FWChainRequest can be used to chain several FWRequest so that one will only starts after another finishes. Note that when used inside FWChainRequest, a single FWRequest will have its own callback and delegate cleared, in favor of the chain request callback.
-
All the requests are stored in this array.
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSArray<FWBaseRequest *> *_Nonnull requestArray;
-
The delegate object of the chain request. Default is nil.
Declaration
Objective-C
@property (nonatomic, weak, nullable) id<FWChainRequestDelegate> 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 (^) (FWChainRequest *_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 (^) (FWChainRequest *_Nonnull __strong) failureCompletionBlock;
-
Tag can be used to identify chain 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 last request that succeed (and causing the chain request to finish).
Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) FWBaseRequest *succeedRequest;
-
The last request that failed (and causing the chain request to fail).
Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) FWBaseRequest *failedRequest;
-
The request interval to start next chain request. Defaults to 0.
Declaration
Objective-C
@property (nonatomic) NSTimeInterval requestInterval;
-
When true, the chain request is stopped if one of the requests fails. Defaults to YES.
Declaration
Objective-C
@property (nonatomic) BOOL stoppedOnFailure;
-
When true, the chain request is stopped if one of the requests succeed. Defaults to NO.
Declaration
Objective-C
@property (nonatomic) BOOL stoppedOnSuccess;
-
Set completion callbacks
Declaration
Objective-C
- (void)setCompletionBlockWithSuccess: (nullable void (^)(FWChainRequest *_Nonnull __strong))success failure:(nullable void (^)( FWChainRequest *_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;
-
Start the chain request, adding first request in the chain to request queue.
Declaration
Objective-C
- (void)start;
-
Stop the chain request. Remaining request in chain will be cancelled.
Declaration
Objective-C
- (void)stop;
-
Convenience method to start the chain request with block callbacks.
Declaration
Objective-C
- (void)startWithCompletionBlockWithSuccess: (nullable void (^)(FWChainRequest *_Nonnull __strong))success failure: (nullable void (^)( FWChainRequest *_Nonnull __strong)) failure;
-
Convenience method to start the chain request with completion block.
Declaration
Objective-C
- (void)startWithCompletion: (nullable void (^)(FWChainRequest *_Nonnull __strong))completion;
-
Add request to request chain.
Declaration
Objective-C
- (void)addRequest:(nonnull FWBaseRequest *)request callback:(nullable FWChainCallback)callback;
Parameters
request
The request to be chained.
callback
The finish callback
-
The request builder for the chain. Note this will be called if all of the requests finished. This block will be called on the main queue.
Declaration
Objective-C
@property (nonatomic, copy, nullable) FWBaseRequest *_Nullable (^) (FWChainRequest *_Nonnull __strong, FWBaseRequest *_Nullable __strong) requestBuilder;
-
Undocumented
Declaration
Objective-C
- (void)toggleAccessoriesWillStartCallBack;
-
Undocumented
Declaration
Objective-C
- (void)toggleAccessoriesWillStopCallBack;
-
Undocumented
Declaration
Objective-C
- (void)toggleAccessoriesDidStopCallBack;
-
Undocumented
Declaration
Objective-C
- (void)startWithWillStart:(nullable void (^)(FWChainRequest *chainRequest))willStart willStop:(nullable void (^)(FWChainRequest *chainRequest))willStop success:(nullable void (^)(FWChainRequest *chainRequest))success failure:(nullable void (^)(FWChainRequest *chainRequest))failure didStop:(nullable void (^)(FWChainRequest *chainRequest))didStop;