RequestStateService Class
The RequestStateService is used to track the state of requests for fetching or updating known resource identifies that are inflight.
Item Index
Methods
getLastRequestForRecord
-
identifier
Retrieve the last completed request for a given resource identity.
Parameters:
-
identifier
StableRecordIdentifier
Returns:
the state of the most recent request for the given identifier
getPendingRequestsForRecord
-
identifier
Retrieve all active requests for a given resource identity.
Parameters:
-
identifier
StableRecordIdentifier
Returns:
an array of request states for any pending requests for the given identifier
subscribeForRecord
-
identifier
-
callback
Subscribe to requests for a given resource identity.
The callback will receive the current state of the request.
interface RequestState {
state: 'pending' | 'fulfilled' | 'rejected';
type: 'query' | 'mutation';
request: Request;
response?: { data: unknown };
}
Note: It should be considered dangerous to use this API for more than simple
state derivation or debugging. The request
and response
properties are poorly
spec'd and may change unexpectedly when shifting what Handlers are in use or how
requests are issued from the Store.
We expect to revisit this API in the near future as we continue to refine the RequestManager ergonomics, as a simpler but more powerful direct integration with the RequestManager for these purposes is likely to be a better long-term design.
Parameters:
-
identifier
StableRecordIdentifier -
callback
(state: RequestState) => void