reactjs - Which is best Immutable JS data structure for JSON Object types in redux.? -


i using spread operators in redux arrange data json object format given below:

filename: redux.js

export default function appdata(state = {}, action) {   switch (action.type) {     case 'add_layers':     return {       ...state, appelements: action.data.appelements     }      case 'add_items':     return {         ...state,appelements:{ ...state.appelements,         layers: { ...state.appelements.layers,           ['layer_1']:{ ...state.appelements.layers.layer_1,             ['items']:{ ...state.appelements.layers.layer_1.items,               [action.objdata.item_id]:{                 "width":action.objdata.width,                 "x":action.objdata.x               },             }           },         }       }     }     default:       return state   } } 

where case 'add_layers': of action.data.appelements add:(data external json file stored object key value pairs)

layers: {   layer_1: {     background: {       width: '100px',       height: '100px',       bgcolor: '#aaaaaa',       bgimage: 'http:bgimage1.png'     },     items: {     }   },   layer_2: {     background: {       width: '200px',       height: '200px',       bgcolor: '#bbbbbb',       bgimage: 'http:bgimage2.png'     },     items: {     }   },   layer_3: {     background: {       width: '300px',       height: '300px',       bgcolor: '#cccccc',       bgimage: 'http:bgimage3.png'     },     items: {     }   } } 

where case 'add_items': add layer_1 items:

yrgroih9: {   width: '100px',   x: '200px' } 

final redux store given below:

{   appelements: {     layers: {       layer_1: {         background: {           width: '100px',           height: '100px',           bgcolor: '#aaaaaa',           bgimage: 'http:bgimage1.png'         },         items: {           yrgroih9: {             width: '100px',             x: '200px'           },           qhy0dukj: {             width: '100px',             x: '200px'           },           '7lw2nvma': {             width: '100px',             x: '200px'           }         }       },       layer_2: {         background: {           width: '200px',           height: '200px',           bgcolor: '#bbbbbb',           bgimage: 'http:bgimage2.png'         },         items: {           sdfsdsvod: {             width: '555px',             x: '111px'           },           sdfcasadf: {             width: '333px',             x: '222px'           },           'xcvxcver': {             width: '555px',             x: '444px'           }         }       },       layer_3: {         background: {           width: '300px',           height: '300px',           bgcolor: '#cccccc',           bgimage: 'http:bgimage3.png'         },         items: {           dfsgdfgfg: {             width: '555px',             x: '111px'           },           sfgdyrsdf: {             width: '333px',             x: '222px'           },           'dsfdhsfdf': {             width: '777px',             x: '444px'           }         }       }     }   } } 

i want move redux spread operators immutable js better functionalities create,read,update , delete in redux store data.

which best immutable js data structure (list, stack, map, orderedmap, set, orderedset , record) suits above given store manipulations in both structure , performance..?


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -