test-tab-demo

This commit is contained in:
Nathan Bierema 2024-08-05 22:05:57 -04:00
parent 14b25d7e9b
commit 4cb3465a94
2 changed files with 19 additions and 19 deletions

View File

@ -33,9 +33,9 @@ const useDevtoolsExtension =
!!(window as unknown as { __REDUX_DEVTOOLS_EXTENSION__: unknown }) && !!(window as unknown as { __REDUX_DEVTOOLS_EXTENSION__: unknown }) &&
getOptions(window.location).useExtension; getOptions(window.location).useExtension;
const enhancer = compose( const enhancer: StoreEnhancer = compose(
applyMiddleware(logger), applyMiddleware(logger),
(next: StoreEnhancerStoreCreator) => { ((next) => {
const instrument = useDevtoolsExtension const instrument = useDevtoolsExtension
? ( ? (
window as unknown as { window as unknown as {
@ -44,9 +44,9 @@ const enhancer = compose(
).__REDUX_DEVTOOLS_EXTENSION__() ).__REDUX_DEVTOOLS_EXTENSION__()
: DevTools.instrument(); : DevTools.instrument();
return instrument(next); return instrument(next);
}, }) as StoreEnhancer,
persistState(getDebugSessionKey()), persistState(getDebugSessionKey()),
); ) as any;
const store = createStore(rootReducer, enhancer); const store = createStore(rootReducer, enhancer);

View File

@ -155,12 +155,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,
@ -169,7 +169,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'
@ -177,13 +177,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,
@ -200,23 +200,23 @@ export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
}, },
} }
: state, : state,
recursive: (state = [], action) => recursive: (state = [], action: DemoAppAction) =>
action.type === 'ADD_RECURSIVE' ? [...state, { ...RECURSIVE }] : state, action.type === 'ADD_RECURSIVE' ? [...state, { ...RECURSIVE }] : state,
immutables: (state = [], action) => immutables: (state = [], action: DemoAppAction) =>
action.type === 'ADD_IMMUTABLE_MAP' ? [...state, IMMUTABLE_MAP] : state, action.type === 'ADD_IMMUTABLE_MAP' ? [...state, IMMUTABLE_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;