mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 08:30:02 +03:00
inspector-monitor-demo
This commit is contained in:
parent
4cb3465a94
commit
54f5e88702
|
@ -32,7 +32,7 @@ const useDevtoolsExtension =
|
||||||
!!(window as unknown as { __REDUX_DEVTOOLS_EXTENSION__: unknown })
|
!!(window as unknown as { __REDUX_DEVTOOLS_EXTENSION__: unknown })
|
||||||
.__REDUX_DEVTOOLS_EXTENSION__ && getOptions(window.location).useExtension;
|
.__REDUX_DEVTOOLS_EXTENSION__ && getOptions(window.location).useExtension;
|
||||||
|
|
||||||
const enhancer = compose(
|
const enhancer: StoreEnhancer = compose(
|
||||||
applyMiddleware(logger),
|
applyMiddleware(logger),
|
||||||
(next: StoreEnhancerStoreCreator) => {
|
(next: StoreEnhancerStoreCreator) => {
|
||||||
const instrument = useDevtoolsExtension
|
const instrument = useDevtoolsExtension
|
||||||
|
@ -45,7 +45,7 @@ const enhancer = compose(
|
||||||
return instrument(next);
|
return instrument(next);
|
||||||
},
|
},
|
||||||
persistState(getDebugSessionKey()),
|
persistState(getDebugSessionKey()),
|
||||||
);
|
) as any;
|
||||||
|
|
||||||
const store = createStore(rootReducer, enhancer);
|
const store = createStore(rootReducer, enhancer);
|
||||||
|
|
||||||
|
|
|
@ -185,12 +185,12 @@ export interface DemoAppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
|
export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
|
||||||
combineReducers<DemoAppState, DemoAppAction>({
|
combineReducers({
|
||||||
timeoutUpdateEnabled: (state = false, action) =>
|
timeoutUpdateEnabled: (state = false, action: DemoAppAction) =>
|
||||||
action.type === 'TOGGLE_TIMEOUT_UPDATE'
|
action.type === 'TOGGLE_TIMEOUT_UPDATE'
|
||||||
? action.timeoutUpdateEnabled
|
? action.timeoutUpdateEnabled
|
||||||
: state,
|
: state,
|
||||||
store: (state = 0, action) =>
|
store: (state = 0, action: DemoAppAction) =>
|
||||||
action.type === 'INCREMENT' ? state + 1 : state,
|
action.type === 'INCREMENT' ? state + 1 : state,
|
||||||
undefined: (state = { val: undefined }) => state,
|
undefined: (state = { val: undefined }) => state,
|
||||||
null: (state = null) => state,
|
null: (state = null) => state,
|
||||||
|
@ -199,7 +199,7 @@ export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
|
||||||
// noop
|
// noop
|
||||||
},
|
},
|
||||||
) => state,
|
) => state,
|
||||||
array: (state = [], action) =>
|
array: (state = [], action: DemoAppAction) =>
|
||||||
action.type === 'PUSH'
|
action.type === 'PUSH'
|
||||||
? [...state, Math.random()]
|
? [...state, Math.random()]
|
||||||
: action.type === 'POP'
|
: action.type === 'POP'
|
||||||
|
@ -207,13 +207,13 @@ export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
|
||||||
: action.type === 'REPLACE'
|
: action.type === 'REPLACE'
|
||||||
? [Math.random(), ...state.slice(1)]
|
? [Math.random(), ...state.slice(1)]
|
||||||
: state,
|
: state,
|
||||||
hugeArrays: (state = [], action) =>
|
hugeArrays: (state = [], action: DemoAppAction) =>
|
||||||
action.type === 'PUSH_HUGE_ARRAY' ? [...state, ...HUGE_ARRAY] : state,
|
action.type === 'PUSH_HUGE_ARRAY' ? [...state, ...HUGE_ARRAY] : state,
|
||||||
hugeObjects: (state = [], action) =>
|
hugeObjects: (state = [], action: DemoAppAction) =>
|
||||||
action.type === 'ADD_HUGE_OBJECT' ? [...state, HUGE_OBJECT] : state,
|
action.type === 'ADD_HUGE_OBJECT' ? [...state, HUGE_OBJECT] : state,
|
||||||
iterators: (state = [], action) =>
|
iterators: (state = [], action: DemoAppAction) =>
|
||||||
action.type === 'ADD_ITERATOR' ? [...state, createIterator()] : state,
|
action.type === 'ADD_ITERATOR' ? [...state, createIterator()] : state,
|
||||||
nested: (state = NESTED, action) =>
|
nested: (state = NESTED, action: DemoAppAction) =>
|
||||||
action.type === 'CHANGE_NESTED'
|
action.type === 'CHANGE_NESTED'
|
||||||
? {
|
? {
|
||||||
...state,
|
...state,
|
||||||
|
@ -230,25 +230,28 @@ export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: state,
|
: state,
|
||||||
recursive: (state: { obj?: unknown }[] = [], action) =>
|
recursive: (state: { obj?: unknown }[] = [], action: DemoAppAction) =>
|
||||||
action.type === 'ADD_RECURSIVE' ? [...state, { ...RECURSIVE }] : state,
|
action.type === 'ADD_RECURSIVE' ? [...state, { ...RECURSIVE }] : state,
|
||||||
immutables: (state: Immutable.Map<string, unknown>[] = [], action) =>
|
immutables: (
|
||||||
|
state: Immutable.Map<string, unknown>[] = [],
|
||||||
|
action: DemoAppAction,
|
||||||
|
) =>
|
||||||
action.type === 'ADD_IMMUTABLE_MAP' ? [...state, IMMUTABLE_MAP] : state,
|
action.type === 'ADD_IMMUTABLE_MAP' ? [...state, IMMUTABLE_MAP] : state,
|
||||||
maps: (state: Map<string, MapValue>[] = [], action) =>
|
maps: (state: Map<string, MapValue>[] = [], action: DemoAppAction) =>
|
||||||
action.type === 'ADD_NATIVE_MAP' ? [...state, NATIVE_MAP] : state,
|
action.type === 'ADD_NATIVE_MAP' ? [...state, NATIVE_MAP] : state,
|
||||||
immutableNested: (state = IMMUTABLE_NESTED, action) =>
|
immutableNested: (state = IMMUTABLE_NESTED, action: DemoAppAction) =>
|
||||||
action.type === 'CHANGE_IMMUTABLE_NESTED'
|
action.type === 'CHANGE_IMMUTABLE_NESTED'
|
||||||
? state.updateIn(
|
? state.updateIn(
|
||||||
['long', 'nested', 0, 'path', 'to', 'a'],
|
['long', 'nested', 0, 'path', 'to', 'a'],
|
||||||
(str: unknown) => (str as string) + '!',
|
(str: unknown) => (str as string) + '!',
|
||||||
)
|
)
|
||||||
: state,
|
: state,
|
||||||
addFunction: (state = null, action) =>
|
addFunction: (state = null, action: DemoAppAction) =>
|
||||||
action.type === 'ADD_FUNCTION' ? { f: FUNC } : state,
|
action.type === 'ADD_FUNCTION' ? { f: FUNC } : state,
|
||||||
addSymbol: (state = null, action) =>
|
addSymbol: (state = null, action: DemoAppAction) =>
|
||||||
action.type === 'ADD_SYMBOL'
|
action.type === 'ADD_SYMBOL'
|
||||||
? { s: window.Symbol('symbol'), error: new Error('TEST') }
|
? { s: window.Symbol('symbol'), error: new Error('TEST') }
|
||||||
: state,
|
: state,
|
||||||
shuffleArray: (state = DEFAULT_SHUFFLE_ARRAY, action) =>
|
shuffleArray: (state = DEFAULT_SHUFFLE_ARRAY, action: DemoAppAction) =>
|
||||||
action.type === 'SHUFFLE_ARRAY' ? shuffle(state) : state,
|
action.type === 'SHUFFLE_ARRAY' ? shuffle(state) : state,
|
||||||
});
|
}) as any;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user