API Docs for: 5.3.1+9967eaf7
Show:

RequestStateService Class

The RequestStateService is used to track the state of requests for fetching or updating known resource identifies that are inflight.

Methods

getLastRequestForRecord

(
  • identifier
)
RequestState | null public

Retrieve the last completed request for a given resource identity.

Parameters:

Returns:

RequestState | null:

the state of the most recent request for the given identifier

getPendingRequestsForRecord

(
  • identifier
)
RequestState public

Retrieve all active requests for a given resource identity.

Parameters:

Returns:

RequestState:

an array of request states for any pending requests for the given identifier

subscribeForRecord

(
  • identifier
  • callback
)
public

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: