DAAsyncRequest
Overview
DAAsyncRequest objects present an ongoing or completed asynchronous request that a DARemoteDataAdapter is executing after one of its begin*
methods was called. The DAAsyncRequest can be used to check the status of the request, assign a delegate (of type DAAsyncRequestDelegate to be informed of progress, success and failures.
Some overloads of the begin*
methods on the DARemoteDataAdapter take a BOOL start
parameter. When passing in YES
, they will return a request that is already started, as do the overloads without start
parameter. When passing in NO
, the returned DAAsyncRequest has not been started yet and can be started by sending it a start
or startInBackground
message.
Please also refer to Asynchronous Requests in Data Abstract (Cocoa) for a more general overview of asynchronous requests, and check out Remote Data Adapter and Data Tables (Xcode).
Location
- Reference: DAAsyncRequest.h
- Namespace: DataAbstract
- Ancestry: NSObject | DAAsyncRequest
adapter
@property (readonly) nonnull DARemoteDataAdapter *adapter
commandOutParameters
Represents dictionary which can contains output parameters with their values after completion of the ExecuteCommandEx request
@property (readonly) nullable NSDictionary *commandOutParameters
commandResult
Represents result value of the executing ExecuteCommand or ExecuteCommandEx requests
@property (readonly) int commandResult
context retain
Represents an any arbitrary object (id), which can be associated with request and later it allows you to identify the particular request object – this can be useful in case when you run several independent requests with the same delegate
@property (retain) id context
customParameters retain
Represents a dictionary of any custom properties wich can be binded to the given request.
@property (retain) nullable NSMutableDictionary *customParameters
delegate assign
Represents a delegate object which will be informed with (and it can handle them) various callbacks: when the request succeeds or fails or the server requests authentication. If no delegate is assigned, the request automatically inherits the delegate from the DARemoteDataAdapter.
@property (assign) id<DAAsyncRequestDelegate> delegate
failureBlock copy
@property (copy) nullable void(^)(NSException * __nonnull) failureBlock
initWithAsyncRequest:adapter:
- (nonnull instancetype) initWithAsyncRequest:(nonnull ROAsyncRequest *)aRequest adapter:(nonnull DARemoteDataAdapter *)aAdapter
Parameters:
- aRequest:
- aAdapter:
request
@property (readonly) nonnull ROAsyncRequest *request
schema
Represents a DASchema instance that can be available after executing beginGetSchema request.
@property (readonly) nullable DASchema *schema
setTables:
- (void) setTables:(NSArray *)tables
Parameters:
- tables:
setType:
- (void) setType:(enum DAAsyncRequestType)type
Parameters:
- type:
start
Starts the request, if it is not already running (see above). While the request itself will be executed in the background, the current thread will be considered the request's context, and any callbacks to the delegate
will happen on the thread that sent the start
message.
- (void) start
startInBackground
Starts the request, if it is not already running (see above). The request itself will be executed in the background, regardless how it was started. However, by starting a request with startInBackground
, any callbacks to the delegate
will happen on a background thread, and not the thread that started the request. The identity of this background thread is undefined and may depend on the underlying communication structure.
If startInBackground
is sent to a request that is already running, an exception will be thrown.
- (void) startInBackground
startInBackgroundWithBlock:
- (void) startInBackgroundWithBlock:(nonnull void^)aBlock
Parameters:
- aBlock:
startWithBlock:
- (void) startWithBlock:(nonnull void^)block
Parameters:
- block:
tableNamed:
Returns reference to the table with the given name
- (nullable DADataTable *) tableNamed:(nonnull NSString *)name
Parameters:
- name:
tables
Array of tables that can be available after succesful GetData request. In can be used in cases when you have requested data for several tables in the single request.
@property (readonly) nullable NSArray *tables
type
Represents the type of the request (is it GetDataTable
or GetSchema
or any from other possible request types).
@property (readonly) enum DAAsyncRequestType type
adapter
@property (readonly) nonnull DARemoteDataAdapter *adapter
commandOutParameters
Represents dictionary which can contains output parameters with their values after completion of the ExecuteCommandEx request
@property (readonly) nullable NSDictionary *commandOutParameters
commandResult
Represents result value of the executing ExecuteCommand or ExecuteCommandEx requests
@property (readonly) int commandResult
context retain
Represents an any arbitrary object (id), which can be associated with request and later it allows you to identify the particular request object – this can be useful in case when you run several independent requests with the same delegate
@property (retain) id context
customParameters retain
Represents a dictionary of any custom properties wich can be binded to the given request.
@property (retain) nullable NSMutableDictionary *customParameters
delegate assign
Represents a delegate object which will be informed with (and it can handle them) various callbacks: when the request succeeds or fails or the server requests authentication. If no delegate is assigned, the request automatically inherits the delegate from the DARemoteDataAdapter.
@property (assign) id<DAAsyncRequestDelegate> delegate
failureBlock copy
@property (copy) nullable void(^)(NSException * __nonnull) failureBlock
request
@property (readonly) nonnull ROAsyncRequest *request
schema
Represents a DASchema instance that can be available after executing beginGetSchema request.
@property (readonly) nullable DASchema *schema
tables
Array of tables that can be available after succesful GetData request. In can be used in cases when you have requested data for several tables in the single request.
@property (readonly) nullable NSArray *tables
type
Represents the type of the request (is it GetDataTable
or GetSchema
or any from other possible request types).
@property (readonly) enum DAAsyncRequestType type
initWithAsyncRequest:adapter:
- (nonnull instancetype) initWithAsyncRequest:(nonnull ROAsyncRequest *)aRequest adapter:(nonnull DARemoteDataAdapter *)aAdapter
Parameters:
- aRequest:
- aAdapter:
setTables:
- (void) setTables:(NSArray *)tables
Parameters:
- tables:
setType:
- (void) setType:(enum DAAsyncRequestType)type
Parameters:
- type:
start
Starts the request, if it is not already running (see above). While the request itself will be executed in the background, the current thread will be considered the request's context, and any callbacks to the delegate
will happen on the thread that sent the start
message.
- (void) start
startInBackground
Starts the request, if it is not already running (see above). The request itself will be executed in the background, regardless how it was started. However, by starting a request with startInBackground
, any callbacks to the delegate
will happen on a background thread, and not the thread that started the request. The identity of this background thread is undefined and may depend on the underlying communication structure.
If startInBackground
is sent to a request that is already running, an exception will be thrown.
- (void) startInBackground
startInBackgroundWithBlock:
- (void) startInBackgroundWithBlock:(nonnull void^)aBlock
Parameters:
- aBlock:
startWithBlock:
- (void) startWithBlock:(nonnull void^)block
Parameters:
- block:
tableNamed:
Returns reference to the table with the given name
- (nullable DADataTable *) tableNamed:(nonnull NSString *)name
Parameters:
- name: