Add demo for ES6 map

From
alexkuz/redux-devtools-inspector/commit/9dfaaabcfba7913fd15ee6ee43627e0c
eb1d5c7b
This commit is contained in:
Zalmoxisus 2018-12-22 01:52:37 +02:00
parent 1bb18a713a
commit bff3e6d684
3 changed files with 39 additions and 15 deletions

View File

@ -143,6 +143,9 @@ class DemoApp extends React.Component {
<Button onClick={this.props.addRecursive} style={styles.button}>
Add Recursive
</Button>
<Button onClick={this.props.addNativeMap} style={styles.button}>
Add Native Map
</Button>
<Button onClick={this.props.addImmutableMap} style={styles.button}>
Add Immutable Map
</Button>
@ -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: () => ({

View File

@ -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

View File

@ -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 => {