Concurrency and cancellation

All requests

concurrency: "all" is the default. Every non-cancelled request may update the snapshot when it settles. isLoading remains true until all active requests finish.

const save = createAsync(saveRecord, { concurrency: "all" });

This is useful for independent actions where every result matters.

Latest request

With concurrency: "latest", older requests may still resolve or reject, but only the newest request can update state or invoke callbacks.

const search = createAsync(searchUsers, { concurrency: "latest" });

This is useful for search, filtering, and route-driven queries where stale responses must not replace newer data.

Abortable handlers

Enable abortable to receive an AbortSignal in the handler context:

const request = createAsync(
  ({ signal }, url: string) => fetch(url, { signal: signal ?? undefined }),
  { abortable: true },
);

request.execute("/api/data");
request.abort();

abort() also invalidates state updates, even when the underlying handler does not observe the signal. reset() invalidates active work and restores the original data.