Class RequestState

public

RequestState extends the concept of PromiseState to provide a reactive wrapper for a request Future which allows you write declarative code around a Future's control flow.

It is useful in both Template and JavaScript contexts, allowing you to quickly derive behaviors and data from pending, error and success states.

The key difference between a Promise and a Future is that Futures provide access to a stream of their content, the identity of the request (if any) as well as the ability to attempt to abort the request.

interface Future<T> extends Promise<T>> {
  getStream(): Promise<ReadableStream>;
  abort(): void;
  lid: StableDocumentIdentifier | null;
}

These additional APIs allow us to craft even richer state experiences.

To get the state of a request, use getRequestState.