UNPKG

redux-state-utils

Version:

Library to help the creation of states in redux

85 lines (79 loc) 1.9 kB
<!doctype html> <html> <script src="../src/state-proxy.js"></script> <script src="../src/utils.js"></script> <script> const state = { products: [ { id: 1, name: 'Nokia', }, { id: 2, name: 'Iphone', }, { id: 3, name: 'Galaxy', }, ], tree: [ { id: 1, name: 'Item 1', children: [ { id: 2, name: 'Item 1.1', children: [ { id: 3, name: 'Item 1.1.1', } ] }, { id: 4, name: 'Item 1.2', } ] }, { id: 5, name: 'Item 2', }, ], user: { name: 'Jonh', roles: [ { id: 1, name: 'Engineer' }, { id: 2, name: 'Manager' }, ], roleActive: { id: 2, name: 'Manager' } }, }; const stateProxy = createStateProxy(state); delete stateProxy.products[0].id; const newState = stateProxy.getNewState(); console.log(newState); // TODO // support to all array methods https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries // proxyState be a state and has a getNewState() method // when set a value that is a proxy is necessary to get the original object OK // create a method __isProxy() OK // create a method __getRawData() OK // </script> <body> </body> </html>