-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
@bigfoodK I have a suggestion about implementation of history. What about keep state using const stateStorage: state[] = [];
let stateStorageIndex;
store.subscribe((nextState) => {
stateStorage.removeElementsAfter(stateStorageIndex);
stateStorage.push(nextState);
stateStorageIndex = stateStorage.length - 1;
});
function Undo() {
const state = stateStorage[stateStorageIndex - 1];
stateStorageIndex -= 1;
setState(state);
}
function Redo() {
const state = stateStorage[stateStorageIndex + 1];
if (!state) {
throw new Error('cant redo');
}
stateStorageIndex += 1;
setState(state);
} Pros : Don't have to set editHistory.push(); |
Consider points
Solutions Consider point 1 Consider point 2 With these solutions, How about just add then, in barActions.ts
like this, Is it look good to you? |
|
Fixed issues. Thank you for your advice. |
Notice
It saves whole state of redux
This can be performance issue
R and Ctrl+Z for undo
Shift+R and Ctrl+Shift+Z for redo