Overview
ThewithAsyncStatus extension provides fine-grained state information about async operations including current state, first-time flags, and historical tracking. It’s typically used internally by withAsync when the status option is enabled.
This extension enables sophisticated UI states like:
- Show skeleton only on first load
- Show spinner on subsequent loads
- Distinguish between “never loaded” and “loaded but stale”
- Handle abort scenarios gracefully
Type Signature
Status Properties
The status atom provides the following boolean flags:Current State Flags
boolean
An async operation is currently in progress
boolean
The last completed operation succeeded
boolean
The last completed operation failed (non-abort errors only)
boolean
The operation has completed (either fulfilled or rejected)
Historical Tracking Flags
boolean
This is the first-ever pending state (useful for initial loading UI)
boolean
At least one async operation has been started
boolean
At least one async operation has completed
State | InitState
The data value (only present when used with
withAsyncData)Status Types
Each possible status state has a corresponding TypeScript type for precise type narrowing:Never Pending State
First Pending State
Fulfilled State
Rejected State
Abort Handling
Aborted operations are treated specially:- They don’t set
isRejectedto true - After an abort, status returns to the last settled state if one exists
- Otherwise, it goes to a “first aborted” state
Return Value
AsyncStatusAtom<State, InitState>
Computed atom that tracks the current async status
Examples
Basic Status Tracking
Conditional UI Rendering
Parallel Requests
Reset During Pending
Abort Handling
Restore State After Abort
With Data Property
Use Cases
Smart Loading States
Error Recovery UI
Progressive Enhancement
Related
- withAsync - Base async state tracking that uses this extension
- withAsyncData - Async data management with status support