A promise represents a future result
An async function can await a promise and continue when it succeeds or fails. The surrounding interface should expose truthful loading, success, empty, and error states that match the work in progress.
State connects data to the interface
State is the current information needed to render a view, such as the query, results, and loading status. Update it from one clear owner so late responses do not overwrite a newer user action.
A familiar example
Loading search suggestions
- Typing starts a request and shows a loading state.
- A newer query cancels or supersedes the older request.
- The page displays only the result that belongs to the latest query, or a useful error if it fails.
What to remember
- Async work finishes later; the page should remain usable meanwhile.
- Model loading, success, empty, and error truthfully.
- Prevent stale results from replacing newer intent.