Overview
ThewithSuspenseRetry extension wraps an async action to automatically retry it when a Promise is thrown (suspension). It keeps retrying until the action completes successfully or throws a non-Promise error.
This is particularly useful when working with atoms that use suspense patterns, where you want actions to wait for suspended data to resolve before continuing.
Type Signature
Warning
Be careful with non-idempotent operations inside the action body, as they may be executed multiple times during retries. Plan your execution logic carefully to handle potential retries safely.Return Value
Returns the same action with automatic suspension retry behavior.Examples
Basic Retry
Fetch User Books After User Loads
Chained Suspense Dependencies
With Error Handling
Multiple Suspended Atoms
How It Works
Use Cases
Dependent Data Loading
Sequential Async Operations
React Component Actions
Important Considerations
Non-Idempotent Operations
Error Recovery
Nested Suspense
Related
- withSuspense - Add suspense support to atoms
- withSuspenseInit - Async atom initialization
- suspense - Helper for suspense values