Skip to content

@continuum-js/std


@continuum-js/std / resource

Function: resource()

resource<A, T>(trigger, fetcher): State<Async<T>>

Defined in: index.ts:181

Turn a stream of requests into a behavior tracking the async lifecycle (idle → loading → ok | error). Requests are stamped with a sequence number, so a slow response to a superseded request is ignored (last-request-wins) — the classic out-of-order-response bug, solved declaratively.

Type Parameters

A

A

T

T

Parameters

trigger

Stream<A>

fetcher

(arg) => Promise<T>

Returns

State<Async<T>>