Skip to content

Commit c415a58

Browse files
committed
Fix function signatures to match actual API
Corrected createAsync signature: - func is positional parameter (before {) - initialValue is required named parameter Corrected createUndoable signature: - Return type is Command<TParam, TResult>, not UndoableCommand - func is positional parameter - initialValue is required named parameter (comes before undo) - undo is required named parameter - undoOnExecutionFailure comes after required params All parameters now match actual source code signatures. Verified against: command_it.dart lines 1373-1389 and 1635-1653
1 parent eddcfc4 commit c415a58

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

docs/documentation/command_it/command_types.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ Here's the complete signature of `createAsync<TParam, TResult>` - the most commo
7070

7171
```dart
7272
static Command<TParam, TResult> createAsync<TParam, TResult>(
73-
Future<TResult> Function(TParam x) func,
74-
TResult initialValue, {
73+
Future<TResult> Function(TParam x) func, {
74+
required TResult initialValue,
7575
ValueListenable<bool>? restriction,
7676
RunInsteadHandler<TParam>? ifRestrictedRunInstead,
7777
bool includeLastResultInCommandResults = false,
@@ -84,8 +84,8 @@ static Command<TParam, TResult> createAsync<TParam, TResult>(
8484

8585
**Required parameters:**
8686

87-
- **`func`** - The async function to wrap. Takes a parameter of type `TParam` and returns `Future<TResult>`
88-
- **`initialValue`** - The command's initial value before first execution. Required for commands with return values because commands are `ValueListenable<TResult>` and need a value immediately. **Not available for void commands** (see NoResult variants below)
87+
- **`func`** - The async function to wrap (positional parameter). Takes a parameter of type `TParam` and returns `Future<TResult>`
88+
- **`initialValue`** - The command's initial value before first execution (required named parameter). Commands are `ValueListenable<TResult>` and need a value immediately. **Not available for void commands** (see NoResult variants below)
8989

9090
**Optional parameters:**
9191

@@ -133,26 +133,28 @@ Undoable commands extend async commands with undo capability. They maintain an `
133133
**Complete signature:**
134134

135135
```dart
136-
static UndoableCommand<TParam, TResult, TUndoState> createUndoable<TParam, TResult, TUndoState>(
137-
Future<TResult> Function(TParam param, UndoStack<TUndoState> undoStack) func,
138-
UndoFn<TUndoState, TResult> undo,
139-
TResult initialValue, {
136+
static Command<TParam, TResult> createUndoable<TParam, TResult, TUndoState>(
137+
Future<TResult> Function(TParam, UndoStack<TUndoState>) func, {
138+
required TResult initialValue,
139+
required UndoFn<TUndoState, TResult> undo,
140+
bool undoOnExecutionFailure = true,
140141
ValueListenable<bool>? restriction,
141142
RunInsteadHandler<TParam>? ifRestrictedRunInstead,
142143
bool includeLastResultInCommandResults = false,
143-
bool undoOnExecutionFailure = true,
144144
ErrorFilter? errorFilter,
145145
ErrorFilterFn? errorFilterFn,
146146
bool notifyOnlyWhenValueChanges = false,
147147
String? debugName,
148148
})
149149
```
150150

151-
**Undoable-specific parameters:**
151+
**Required parameters:**
152+
153+
- **`func`** - Your async function that receives **TWO parameters**: the command parameter (`TParam`) AND the undo stack (`UndoStack<TUndoState>`) where you push state snapshots (positional parameter)
152154

153-
- **`func`** - Your async function that receives **TWO parameters**: the command parameter (`TParam`) AND the undo stack (`UndoStack<TUndoState>`) where you push state snapshots
155+
- **`initialValue`** - The command's initial value before first execution (required named parameter)
154156

155-
- **`undo`** - Handler function called to perform the undo operation:
157+
- **`undo`** - Handler function called to perform the undo operation (required named parameter):
156158
```dart
157159
typedef UndoFn<TUndoState, TResult> = FutureOr<TResult> Function(
158160
UndoStack<TUndoState> undoStack,
@@ -161,7 +163,9 @@ static UndoableCommand<TParam, TResult, TUndoState> createUndoable<TParam, TResu
161163
```
162164
Pop state from the stack and restore it. Called when user manually undos or when `undoOnExecutionFailure: true` and execution fails
163165

164-
- **`undoOnExecutionFailure`** - When `true`, automatically calls the undo handler and restores state if the command fails. Perfect for optimistic updates that need rollback on error
166+
**Optional parameters:**
167+
168+
- **`undoOnExecutionFailure`** - When `true` (default), automatically calls the undo handler and restores state if the command fails. Perfect for optimistic updates that need rollback on error
165169

166170
**Type parameters:**
167171

0 commit comments

Comments
 (0)