UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

25 lines (24 loc) 833 B
import type { Endpoint } from "../endpoint/Endpoint.js"; import { NONE } from "../util/constants.js"; import { Store } from "./Store.js"; /** * Store object that loads a result from an API endpoint and manages its state. * * @todo Needs support for `EndpointOptions` to set headers etc. */ export declare class EndpointStore<P, R> extends Store<R> { static CANCELLED: symbol; readonly endpoint: Endpoint<P, R>; private _payload; private _abort; get payload(): P; set payload(next: P); /** Maximum age data can be before a fetch is triggered (defaults to 5 minutes). */ maxAge: number; get value(): R; set value(value: R | typeof NONE); constructor(endpoint: Endpoint<P, R>, payload: P); refetch(): Promise<void>; /** Call the API now to fetch the data. */ private _call; }