-
Notifications
You must be signed in to change notification settings - Fork 44
Closed
Description
Hi,
if I execute clearStack directly in a store method after reverting / initializing a part of the store, the clearStack is executed before the store is modified and the undo/redo stack gets the change as initial value.
export const EditorStore = signalStore(
{ providedIn: 'root' },
...
withUndoRedo({
maxStackSize: 100,
keys: ['selectedFile']
}),
withMethods((store) => {
...
selectFile(file: ProjectFile) {
patchState(store, {
selectedFile: selected,
});
store.clearStack();
},
...
});
The problem may be that clearStack is executed synchronously, whereas the undo/redo uses an effect that is executed asynchronously.
The solution might be to use watchState instead of effect, which is executed synchronously.
Am I right? Should I create a pull request with this fix?
Metadata
Metadata
Assignees
Labels
No labels