Class RequestStateService
publicThe RequestStateService is used to track the state of requests for fetching or updating known resource identifies that are inflight.
getLastRequestForRecord (identifier) RequestState | null public
Defined in ../packages/store/src/-private/network/request-cache.ts:210
- identifier
- StableRecordIdentifier
- returns
- RequestState | null
the state of the most recent request for the given identifier
Retrieve the last completed request for a given resource identity.
getPendingRequestsForRecord (identifier) RequestState[] public
Defined in ../packages/store/src/-private/network/request-cache.ts:195
- identifier
- StableRecordIdentifier
- returns
- RequestState[]
an array of request states for any pending requests for the given identifier
Retrieve all active requests for a given resource identity.
subscribeForRecord (identifier, callback) public
Defined in ../packages/store/src/-private/network/request-cache.ts:159
- identifier
- StableRecordIdentifier
- callback
- (state: RequestState) => void
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.