You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Corrected createUndoable signature:
- func receives UndoStack<TUndoState>, not TUndoState value
- undo is UndoFn<TUndoState, TResult> with signature (UndoStack, Object? reason)
- Updated descriptions to reflect actual API
The function works with the undo stack directly to push/pop state snapshots, not individual state values.
Verified against source: command_it.dart:1636 and undoable_command.dart:42-43
-**`func`** - Your async function that receives **TWO parameters**: the command parameter (`TParam`) AND the undo state (`TUndoState`) returned by the undo handler
153
+
-**`func`** - Your async function that receives **TWO parameters**: the command parameter (`TParam`) AND the undo stack (`UndoStack<TUndoState>`) where you push state snapshots
154
154
155
-
-**`undo`** - Handler function called before execution to capture the state snapshot:
155
+
-**`undo`** - Handler function called to perform the undo operation:
Return the state needed to undo this operation (e.g., the old value before modification)
162
+
Pop state from the stack and restore it. Called when user manually undos or when `undoOnExecutionFailure: true` and execution fails
160
163
161
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
0 commit comments