Skip to content

Commit 52dc5e6

Browse files
committed
Move includeLastResultInCommandResults details to command_results.md
Changes: - Expanded command_results.md section with detailed explanation of when the flag applies (execution AND error states) - Added common use cases (pull-to-refresh, stale-while-revalidate, error recovery, optimistic UI) - Added "When to use" guidance with examples of good and bad scenarios - Simplified command_types.md descriptions to be brief with links to detailed explanation - Removed AI warning banner from command_results.md Result: Detailed explanation lives in one canonical place (command_results.md) with brief summaries and links in command_types.md
1 parent 5db4628 commit 52dc5e6

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

docs/documentation/command_it/command_results.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Command Results
22

3-
::: warning AI-Generated Content Under Review
4-
This documentation was generated with AI assistance and is currently under review. While we strive for accuracy, there may be errors or inconsistencies. Please report any issues you find.
5-
:::
6-
73
Deep dive into `CommandResult` - the comprehensive state object that combines execution state, result data, errors, and parameters in a single observable property.
84

95
## Overview
@@ -88,7 +84,7 @@ Error: { data: null, error: Exception(), isRunning: false }
8884

8985
### includeLastResultInCommandResults
9086

91-
Set `includeLastResultInCommandResults: true` to keep showing old data:
87+
By default, `CommandResult.data` becomes `null` during command execution and when errors occur. Set `includeLastResultInCommandResults: true` to keep the last successful value visible in both states:
9288

9389
```dart
9490
Command.createAsync<String, List<Todo>>(
@@ -98,6 +94,11 @@ Command.createAsync<String, List<Todo>>(
9894
);
9995
```
10096

97+
**When this flag affects behavior:**
98+
99+
1. **During execution** (`isRunning: true`) - Old data remains in `result.data` instead of becoming `null`
100+
2. **During error states** (`hasError: true`) - Old data remains in `result.data` instead of becoming `null`
101+
101102
**Modified flow:**
102103

103104
```
@@ -113,7 +114,19 @@ Running: { data: [old results], error: null, isRunning: true } ← Still vis
113114
Error: { data: [old results], error: Exception(), isRunning: false } ← Still visible
114115
```
115116

116-
**Use case:** Pull-to-refresh, stale-while-revalidate pattern
117+
**Common use cases:**
118+
119+
- **Pull-to-refresh** - Show stale data while loading fresh data
120+
- **Stale-while-revalidate** - Keep showing old content during updates
121+
- **Error recovery** - Display last known good data even when errors occur
122+
- **Optimistic UI** - Maintain UI stability during background refreshes
123+
124+
**When to use:**
125+
- ✅ List/feed refresh scenarios where empty states look jarring
126+
- ✅ Search results that update incrementally
127+
- ✅ Data that's better stale than absent
128+
- ❌ Login/authentication where stale data is misleading
129+
- ❌ Critical data where showing old values during errors is unsafe
117130

118131
## Result Properties
119132

docs/documentation/command_it/command_types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static Command<TParam, TResult> createAsync<TParam, TResult>(
7171

7272
- **`ifRestrictedRunInstead`** - Alternative function called when command is restricted (e.g., show login dialog). See [Restrictions](/documentation/command_it/restrictions)
7373

74-
- **`includeLastResultInCommandResults`** - When `true`, includes the last successful value in `CommandResult` during execution **and error states**. When `false` (default), `CommandResult.data` is `null` during execution and errors. Useful for refresh scenarios where you want old data to remain visible while loading new data or when errors occur
74+
- **`includeLastResultInCommandResults`** - When `true`, keeps the last successful value visible in `CommandResult.data` during execution and error states. Default is `false` (data becomes `null` during these states). See [Command Results - includeLastResultInCommandResults](/documentation/command_it/command_results#includelastresultincommandresults) for detailed explanation and use cases
7575

7676
- **`errorFilter`/`errorFilterFn`** - Configure how errors are handled (local handler, global handler, or both). See [Error Handling](/documentation/command_it/error_handling) and [Error Filters](/documentation/command_it/error_filters)
7777

@@ -174,7 +174,7 @@ Most factory functions share these parameters:
174174

175175
- **`errorFilter`/`errorFilterFn`** - Configure error handling strategy. See [Error Handling](/documentation/command_it/error_handling) and [Error Filters](/documentation/command_it/error_filters).
176176

177-
- **`includeLastResultInCommandResults`** - When `true`, keeps previous result visible during execution. Useful for "refresh" scenarios where old data should remain visible while loading new data.
177+
- **`includeLastResultInCommandResults`** - When `true`, keeps previous result visible during execution and error states. See [Command Results - includeLastResultInCommandResults](/documentation/command_it/command_results#includelastresultincommandresults) for detailed explanation.
178178

179179
- **`notifyOnlyWhenValueChanges`** - When `true`, only notifies listeners if the value actually changes. Default is to notify on every execution.
180180

0 commit comments

Comments
 (0)