Skip to content
qubeejs/angular
API/qubeeHttpResource

qubeeHttpResource

function@qubeejs/angular/httphttp/src/qubee-http-resource.ts

Fetch the page a list request asks for, and fetch again when it changes

Takes the request of injectQubeeList() — or any function returning a core ListRequest — and returns the parsed page as a signal. Built on Angular’s httpResource(), so it goes through HttpClient and your interceptors, aborts a request a newer one has made stale, and needs provideHttpClient() and Angular 19.2 or later.

  • Fetches once per navigation, never per keystroke: a list’s request changes only when the URI or the headers do.
  • Sends the request’s headers — PostgREST’s Range in RANGE mode — and hands the response headers to paginate(), so header-driven drivers (PostgREST, WordPress, Ransack) read their totals without extra code.
  • Keeps the previous page on screen while the next one loads.
  • A null request fetches nothing.
qubeeHttpResource<T extends object>(request: () => ListRequest | null | undefined, options: QubeeHttpResourceOptions): QubeeHttpResourceRef<T>
Parameter Type Description
request () => ListRequest | null | undefined The request to fetch; null or undefined fetches nothing.
options QubeeHttpResourceOptions Request options, the injector, and whether to keep the previous page.

Returns — The page and the state of its request, as signals

Throws — If called outside an injection context without an injector.

export class ArticlesComponent {
protected readonly list = injectQubeeList(articleList);
protected readonly articles = qubeeHttpResource<Article>(this.list.request);
}
@for (article of articles.value()?.data; track article.id) { <p>{{ article.title }}</p> }