EndpointCache.get()method
Get (or create) the EndpointStore for the given payload.
get(payload: P, caller: AnyCaller = this.get): EndpointStore<P, R>
new EndpointCache<P, R>(endpoint: Endpoint<P, R>, provider: APIProvider<P, R>)
| Param | Type | |
|---|---|---|
endpoint | Endpoint<P, R> | The endpoint that every cached store fetches from. required |
provider | APIProvider<P, R> | The APIProvider used to render URLs and fetch results. required |
| Return | |
|---|---|
EndpointCache<P, R> | Cache of EndpointStore objects for a single endpoint, keyed by the rendered request URL of each payload. |
| Property | Type | |
|---|---|---|
.endpoint | Endpoint<P, R> | The endpoint that every store in this cache fetches from. required readonly |
.provider | APIProvider<P, R> |
Cache of EndpointStore objects for a single endpoint, keyed by the rendered request URL of each payload.
get(payload) to retrieve or create the EndpointStore for a given payload.EndpointStore and clears the map.const cache = new EndpointCache(getUser, provider);
const user = await cache.call({ id: "abc" });Get (or create) the EndpointStore for the given payload.
get(payload: P, caller: AnyCaller = this.get): EndpointStore<P, R>
Fetch (or return a cached result) for the given payload.
call(payload: P, maxAge: number = AVOID_REFRESH, caller: AnyCaller = this.call): Promise<R>
Invalidate a specific store so the next read refetches.
invalidate(payload: P, caller: AnyCaller = this.invalidate): void
Invalidate all stores so the next read of any payload refetches.
invalidateAll(): void
Trigger a refetch on a specific store.
refresh(payload: P, maxAge?: number, caller: AnyCaller = this.invalidate): Promise<void>
Trigger a refetch on all stores.
refreshAll(maxAge?: number): Promise<void>