Skip to content

Commit 7f539c4

Browse files
committed
0.2.5: configurable action types, closes #3
1 parent 3f7dc26 commit 7f539c4

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ undoable({
8686
limit: false, // set to a number to turn on a limit for the history
8787
debug: false, // set to `true` to turn on debugging
8888
filter: () => true, // see `Filtering Actions` section
89+
undoType: ActionTypes.UNDO, // define a custom action type for this undo action
90+
redoType: ActionTypes.REDO, // define a custom action type for this redo action
8991
})
9092
```
9193

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-undo",
3-
"version": "0.2.3",
3+
"version": "0.2.5",
44
"description": "simple undo/redo functionality for redux state containers",
55
"main": "lib/index.js",
66
"scripts": {

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,19 @@ export default function undoable(reducer, rawConfig = {}) {
6969
index: rawConfig.initialIndex || -1,
7070
limit: rawConfig.limit,
7171
filter: rawConfig.filter || () => true,
72+
undoType: rawConfig.undoType || ActionTypes.UNDO,
73+
redoType: rawConfig.redoType || ActionTypes.REDO,
7274
};
7375

7476
return (state, action) => {
7577
debug('enhanced reducer called:', state, action);
7678
let res;
7779
switch (action.type) {
78-
case ActionTypes.UNDO:
80+
case config.undoType:
7981
res = undo(state, action.steps);
8082
return res ? res : state;
8183

82-
case ActionTypes.REDO:
84+
case config.redoType:
8385
res = redo(state, action.steps);
8486
return res ? res : state;
8587

0 commit comments

Comments
 (0)