Skip to content

@deltares/fews-web-oc-composables


@deltares/fews-web-oc-composables / sharedRequest

Function: sharedRequest() ​

sharedRequest<T>(key, run, signal?): Promise<T>

Defined in: shared/sharedRequest.ts:144

Alpha

Runs run at most once per key while a request with that key is pending. Concurrent callers with the same key share the result.

Aborting signal only detaches this caller; the underlying request is aborted when all callers have detached. Settled requests are not cached, so subsequent calls start a new request (HTTP caching is left to the browser).

Type Parameters ​

T ​

T

Parameters ​

key ​

string

Identifies the request, e.g. its normalised URL.

run ​

(signal) => Promise<T>

Starts the request, it must honour the provided abort signal.

signal? ​

AbortSignal

Optional signal to detach this caller.

Returns ​

Promise<T>

The (shared) result of run.