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

View File

@ -155,12 +155,12 @@ export interface DemoAppState {
}
export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
combineReducers<DemoAppState, DemoAppAction>({
timeoutUpdateEnabled: (state = false, action) =>
combineReducers({
timeoutUpdateEnabled: (state = false, action: DemoAppAction) =>
action.type === 'TOGGLE_TIMEOUT_UPDATE'
? action.timeoutUpdateEnabled
: state,
store: (state = 0, action) =>
store: (state = 0, action: DemoAppAction) =>
action.type === 'INCREMENT' ? state + 1 : state,
undefined: (state = { val: undefined }) => state,
null: (state = null) => state,
@ -169,7 +169,7 @@ export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
// noop
},
) => state,
array: (state = [], action) =>
array: (state = [], action: DemoAppAction) =>
action.type === 'PUSH'
? [...state, Math.random()]
: action.type === 'POP'
@ -177,13 +177,13 @@ export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
: action.type === 'REPLACE'
? [Math.random(), ...state.slice(1)]
: state,
hugeArrays: (state = [], action) =>
hugeArrays: (state = [], action: DemoAppAction) =>
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,
iterators: (state = [], action) =>
iterators: (state = [], action: DemoAppAction) =>
action.type === 'ADD_ITERATOR' ? [...state, createIterator()] : state,
nested: (state = NESTED, action) =>
nested: (state = NESTED, action: DemoAppAction) =>
action.type === 'CHANGE_NESTED'
? {
...state,
@ -200,23 +200,23 @@ export const rootReducer: Reducer<DemoAppState, DemoAppAction> =
},
}
: state,
recursive: (state = [], action) =>
recursive: (state = [], action: DemoAppAction) =>
action.type === 'ADD_RECURSIVE' ? [...state, { ...RECURSIVE }] : state,
immutables: (state = [], action) =>
immutables: (state = [], action: DemoAppAction) =>
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'
? state.updateIn(
['long', 'nested', 0, 'path', 'to', 'a'],
(str: unknown) => (str as string) + '!',
)
: state,
addFunction: (state = null, action) =>
addFunction: (state = null, action: DemoAppAction) =>
action.type === 'ADD_FUNCTION' ? { f: FUNC } : state,
addSymbol: (state = null, action) =>
addSymbol: (state = null, action: DemoAppAction) =>
action.type === 'ADD_SYMBOL'
? { s: window.Symbol('symbol'), error: new Error('TEST') }
: state,
shuffleArray: (state = DEFAULT_SHUFFLE_ARRAY, action) =>
shuffleArray: (state = DEFAULT_SHUFFLE_ARRAY, action: DemoAppAction) =>
action.type === 'SHUFFLE_ARRAY' ? shuffle(state) : state,
});
}) as any;