From bff3e6d684c7d963a574156acfb0a91eb1d12151 Mon Sep 17 00:00:00 2001 From: Zalmoxisus Date: Sat, 22 Dec 2018 01:52:37 +0200 Subject: [PATCH] Add demo for ES6 map From alexkuz/redux-devtools-inspector/commit/9dfaaabcfba7913fd15ee6ee43627e0c eb1d5c7b --- .../demo/src/js/DemoApp.jsx | 4 ++ .../demo/src/js/reducers.js | 46 +++++++++++++------ .../src/DevtoolsInspector.js | 4 +- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/packages/redux-devtools-inspector/demo/src/js/DemoApp.jsx b/packages/redux-devtools-inspector/demo/src/js/DemoApp.jsx index 608b8748..c7f3e930 100644 --- a/packages/redux-devtools-inspector/demo/src/js/DemoApp.jsx +++ b/packages/redux-devtools-inspector/demo/src/js/DemoApp.jsx @@ -143,6 +143,9 @@ class DemoApp extends React.Component { + @@ -230,6 +233,7 @@ export default connect( addIterator: () => ({ type: 'ADD_ITERATOR' }), addHugeObect: () => ({ type: 'ADD_HUGE_OBJECT' }), addRecursive: () => ({ type: 'ADD_RECURSIVE' }), + addNativeMap: () => ({ type: 'ADD_NATIVE_MAP' }), addImmutableMap: () => ({ type: 'ADD_IMMUTABLE_MAP' }), changeImmutableNested: () => ({ type: 'CHANGE_IMMUTABLE_NESTED' }), hugePayload: () => ({ diff --git a/packages/redux-devtools-inspector/demo/src/js/reducers.js b/packages/redux-devtools-inspector/demo/src/js/reducers.js index 588b9eee..b944b352 100644 --- a/packages/redux-devtools-inspector/demo/src/js/reducers.js +++ b/packages/redux-devtools-inspector/demo/src/js/reducers.js @@ -25,6 +25,25 @@ const IMMUTABLE_MAP = Immutable.Map({ seq: Immutable.Seq.of(1, 2, 3, 4, 5, 6, 7, 8) }); +const NATIVE_MAP = new window.Map([ + ['map', new window.Map([ + [{ first: true }, 1], + ['second', 2] + ])], + ['weakMap', new window.WeakMap([ + [{ first: true }, 1], + [{ second: 1 }, 2] + ])], + ['set', new window.Set([ + { first: true }, + 'second' + ])], + ['weakSet', new window.WeakSet([ + { first: true }, + { second: 1 } + ])] +]); + /* eslint-enable babel/new-cap */ const HUGE_ARRAY = Array.from({ length: 5000 }) @@ -71,23 +90,24 @@ export default { iterators: (state=[], action) => action.type === 'ADD_ITERATOR' ? [...state, createIterator()] : state, nested: (state=NESTED, action) => - action.type === 'CHANGE_NESTED' ? - { - ...state, - long: { - nested: [{ - path: { - to: { - a: state.long.nested[0].path.to.a + '!' - } + action.type === 'CHANGE_NESTED' ? { + ...state, + long: { + nested: [{ + path: { + to: { + a: state.long.nested[0].path.to.a + '!' } - }] - } - } : state, + } + }] + } + } : state, recursive: (state=[], action) => action.type === 'ADD_RECURSIVE' ? [...state, { ...RECURSIVE }] : state, immutables: (state=[], action) => action.type === 'ADD_IMMUTABLE_MAP' ? [...state, IMMUTABLE_MAP] : state, + maps: (state=[], action) => action.type === 'ADD_NATIVE_MAP' ? + [...state, NATIVE_MAP] : state, immutableNested: (state=IMMUTABLE_NESTED, action) => action.type === 'CHANGE_IMMUTABLE_NESTED' ? state.updateIn( ['long', 'nested', 0, 'path', 'to', 'a'], @@ -96,7 +116,7 @@ export default { addFunction: (state=null, action) => action.type === 'ADD_FUNCTION' ? { f: FUNC } : state, addSymbol: (state=null, action) => action.type === 'ADD_SYMBOL' ? - { s: window.Symbol('symbol') } : state, + { s: window.Symbol('symbol'), error: new Error('TEST') } : state, shuffleArray: (state=DEFAULT_SHUFFLE_ARRAY, action) => action.type === 'SHUFFLE_ARRAY' ? shuffle(state) : state diff --git a/packages/redux-devtools-inspector/src/DevtoolsInspector.js b/packages/redux-devtools-inspector/src/DevtoolsInspector.js index 7da39aff..d7dd7e7f 100644 --- a/packages/redux-devtools-inspector/src/DevtoolsInspector.js +++ b/packages/redux-devtools-inspector/src/DevtoolsInspector.js @@ -116,11 +116,11 @@ export default class DevtoolsInspector extends Component { componentDidMount() { this.updateSizeMode(); - this.updateSizeTimeout = window.setInterval(this.updateSizeMode.bind(this), 150); + this.updateSizeTimeout = setInterval(this.updateSizeMode.bind(this), 150); } componentWillUnmount() { - window.clearTimeout(this.updateSizeTimeout); + clearTimeout(this.updateSizeTimeout); } updateMonitorState = monitorState => {