API reference > @kontsedal/olas-core > AsyncState
AsyncState type
The ten reactive signals + four actions a subscriber sees for any async resource (LocalCache<T> or a Query subscription). Spec §20.4.
data/error/status— current outcome. -isLoading— true only on the first pending fetch (nodatayet). -isFetching— true on any pending fetch. -isStale— true whenstaleTimehas elapsed since the last fetch, hydrated row or canonical write. An optimisticsetDatadoes not reset it. -lastUpdatedAt— epoch ms of the last change todata, an optimisticsetDataincluded. -hasPendingMutations— at least one mutation has a snapshot on this entry. -isPaused— a fetch is parked waiting for network reconnect. -isEnabled— false while a subscription'senabledreturns false; always true for a local cache.
Actions: - refetch() — force a fetch; resolves with the result. - reset() — clear error + status without re-fetching. - cancel() — abort the in-flight fetch, if any, and drop one parked for the network. - firstValue() — resolves at once when data for the current key is already there, even while a background refetch runs or after one failed. Otherwise it resolves on the first success and rejects on the first failure. The previous key's data that keepPreviousData keeps on screen does not count. It is the promise to hand to Suspense or React 19's use(...). It never waits on nothing: on an idle entry with no fetch coming, as after a cancelled first load, it starts one.
status reads 'pending' during every fetch, a background refetch included, while data stays. Test data !== undefined for "something to show".
Signature:
type AsyncState<T> = {
data: ReadSignal<T | undefined>;
error: ReadSignal<unknown | undefined>;
status: ReadSignal<AsyncStatus>;
isLoading: ReadSignal<boolean>;
isFetching: ReadSignal<boolean>;
isStale: ReadSignal<boolean>;
lastUpdatedAt: ReadSignal<number | undefined>;
hasPendingMutations: ReadSignal<boolean>;
isPaused: ReadSignal<boolean>;
isEnabled: ReadSignal<boolean>;
refetch: () => Promise<T>;
reset: () => void;
cancel: () => void;
firstValue: () => Promise<T>;
};References: ReadSignal, AsyncStatus