redux-persist-transform-filter
Filter transformator for redux-persist
Installation
npm install redux-persist-transform-filter
Usage
import { createFilter, createBlacklistFilter } from 'redux-persist-transform-filter';
import createFilter, { createBlacklistFilter } from 'redux-persist-transform-filter';
const saveSubsetFilter = createFilter(
'myReducerOne',
['keyYouWantToSave1', 'keyYouWantToSave2']
);
const saveSubsetBlacklistFilter = createBlacklistFilter(
'myReducerTwo',
['keyYouDontWantToSave1', 'keyYouDontWantToSave2']
);
const loadSubsetFilter = createFilter(
'myReducerThree',
null,
['keyYouWantToLoad1', 'keyYouWantToLoad2']
);
const saveAndloadSubsetFilter = createFilter(
'myReducerFour',
['one', 'two']
['three', 'four']
);
const predicateFilter = persistFilter(
'form',
[
{ path: 'one', filterFunction: (item: any): boolean => item.mustBeStored },
{ path: 'two', filterFunction: (item: any): boolean => item.mustBeStored },
],
'whitelist'
)
const normalPathFilter = persistFilter(
'form',
['one', 'two'],
'whitelist'
)
persistStore(store, {
transforms: [
saveSubsetFilter,
saveSubsetBlacklistFilter,
loadSubsetFilter,
saveAndloadSubsetFilter,
]
});
Example project
git clone https://github.com/edy/redux-persist-transform-filter-example.git
cd redux-persist-transform-filter-example
npm install
npm start