Extend withUndoRedo with custom keys
Closed this issue · 2 comments
marcindz88 commented
Hi, I would like to use withUndoRedo feature, but also with other store keys that are not necessarily entities or collections. As far as I checked, we could add options keys or custom keys to feature config and append these keys to those created by the collection mapper or possibly include only specified keys.
Also I am worried by the deep comparison JSON stringify performance in large stores, but I have not yet checked if it's going to cause an issue for me.
Have you considered implementing undo-redo by only keeping action diff and not whole store for given keys?
marcindz88 commented
It would also be possible to infer the available keys as follows:
export function withUndoRedo<Input extends SignalStoreFeatureResult>(options: {
maxStackSize?: number;
keys?: (keyof Input['state'])[];
}): SignalStoreFeature<
EmptyFeatureResult & Input,
EmptyFeatureResult & {
computed: {
canUndo: Signal<boolean>;
canRedo: Signal<boolean>;
};
methods: {
undo: () => void;
redo: () => void;
};
}
>
rainerhahnekamp commented
Also from here: Thanks and good work @marcindz88