Skip to content

Library that allow you to undo any redux action, not only last

Notifications You must be signed in to change notification settings

vbrvk/redux-undo-any

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redux-undo-any

Library that allow you to undo any redux action, not only last

Get started

migration from original redux:

-import { createStore } from 'redux';
+import createStoreCreator from 'redux-undo-any';

+const createStore = createStoreCreator(options);

const store = createStore(reducer, initState, enhancer);

using

import createStoreCreator, { undoAction } from 'redux-undo-any';

const createStore = createStoreCreator(options);

const store = createStore(reducer, initState, enhancer);

// some code

store.dispatch(undoAction((a) => a.type === 'INC')); // undo all 'INC' actions 

API

createStoreCreator

take options as parameter and returns createStore function

field description defaultValue
actionHistorySize defined size of action history. Only last actionHistorySize can be undone 1000
  defaultOptions = {
    actionHistorySize: 1000
  }

undoAction

Takes testFunction as parameter and return redux action to dispatch. Dispatched action will undo all last actionHistorySize actions for which testFunction(action) is true

import { undoAction } from 'redux-undo-any';

// some code

// undo all actions which `type` is 'SET' and `payload.id` equal 100
store.dispatch(
  undoAction(action => action.type === 'SET' && action.payload.id === 100)
);

About

Library that allow you to undo any redux action, not only last

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published