English | 简体中文
An redo/undo library on @ngrx/store. According to the redux-undo modification,the function is basically the same as the redux-undo@1.0.0-beta7. The test code is also from redux-undo (since the Slices are not used, this part of the test code has been removed)。
npm install --save ngrx-history
import { undoable } from 'ngrx-history';
export const counterReducer: ActionReducer<number, AppActions.UnionAction> = (
state = 0,
action
) => {
switch (action.type) {
case AppActions.ActionTypes.INCREMENT:
return state + 1;
case AppActions.ActionTypes.DECREMENT:
return state - 1;
default:
return state;
}
};
export const undoableCounterReducer = undoable(counterReducer, {
limit: 3
});