Package Exports
- redux-data-set
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-data-set) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Redux Data Set
Simple Redux data manager
Installation
Standart npm installation
npm i --save redux-data-set
Adding of the dataSet Reducer
import { combineReducers } from 'redux';
import createDataReducer from 'redux-data-set';
const yourReducer = createDataReducer({ name: 'yourDataSlice' });
export default combineReducers({
...otherReducers,
yourReducer
});
Usage
Actions
import { dataCollectionClean, dataCollectionPush, dataCollectionRemove } from 'redux-data-set';
// Add item(s) to data set.
dataCollectionPush('yourDataSlice', 'foo');
dataCollectionPush('yourDataSlice', ['foo', 'bar']);
dataCollectionPush('yourDataSlice', [
{ id: 'foo', value: 'Foo', ...otherProperties },
{ id: 'bar', value: 'Bar', ...otherProperties },
]);
// Remove items.
return dataCollectionRemove('yourDataSlice', { id: 'foo' });
return dataCollectionRemove('yourDataSlice', ({ value }) => value !== 'Bar' && value.length > 3);
// Reset whole collection.
return dataCollectionClean('yourDataSlice');
Data selection
import { connect } from 'redux';
import { collectionSelector } from 'redux-data-set';
connect(state => ({
items: collectionSelector(state, 'yourDataSlice'),
otherItems: collectionSelector(state, 'otherDataSlice')
}))(YourComponent);