Napoleon's Penguin Mascot

    redux-entities-immutable

    0.0.2 • Public • Published

    Redux Entities Immutable

    build status npm version

    Higher-order reducer for store entities received from gaearon's normalizr and makes it easy to handle them.

    Installation

    npm install --save redux-entities-immutable
    

    Usage

    WIP

    Use with combineEntitiesReducers

    import { combineEntitiesReducers } from 'redux-entities-immutable';
    import { contacts, groups, images, notes } from './entities'
     
    export default combineEntitiesReducers({
        contacts,
        groups,
        images,
        notes
    });
     

    Use with entitiesReducer

    import { combineReducers } from 'redux';
    import { entitiesReducer } from 'redux-entities-immutable';
     
    function contacts(state = {}, action) {
     
        const { type, /* , payload */ meta } = action;
     
        switch (type) {
     
        case UPDATE_CONTACT:
        case REMOVE_CONTACT:
            return state.merge({ [payload.id]: { isPending: true } });
     
        case UPDATE_CONTACT_SUCCESS:
            return state.merge({ [payload.id]: { isPending: false } });
     
        case REMOVE_CONTACT_SUCCESS:
            return state.delete(meta.id);
     
        default:
            return state;
        }
    }
     
    export default combineReducers({
        contacts: entitiesReducer(contacts, 'contacts')
    });
     

    Install

    npm i redux-entities-immutable

    DownloadsWeekly Downloads

    1

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • beautyfree