Setup typescripted listenerMiddleware
parent
f30edc9700
commit
19c189c37d
|
@ -0,0 +1,13 @@
|
|||
import { createListenerMiddleware, addListener } from '@reduxjs/toolkit';
|
||||
import type { TypedStartListening, TypedAddListener } from '@reduxjs/toolkit';
|
||||
import { AppDispatch, RootState } from 'app/store';
|
||||
|
||||
export const listenerMiddleware = createListenerMiddleware();
|
||||
export type AppStartListening = TypedStartListening<RootState, AppDispatch>;
|
||||
|
||||
export const startAppListening =
|
||||
listenerMiddleware.startListening as AppStartListening;
|
||||
export const addAppListener = addListener as TypedAddListener<
|
||||
RootState,
|
||||
AppDispatch
|
||||
>;
|
|
@ -1,4 +1,5 @@
|
|||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import { listenerMiddleware } from './listenerMiddleware';
|
||||
import { pokedexApi } from 'features/Pokedex/pokedexApi';
|
||||
import { pokedexSlice } from 'features/Pokedex/pokedexSlice';
|
||||
|
||||
|
@ -11,7 +12,10 @@ export const store = configureStore({
|
|||
[pokedexApi.reducerPath]: pokedexApi.reducer,
|
||||
},
|
||||
middleware: getDefaultMiddleware =>
|
||||
getDefaultMiddleware().concat(pokedexApi.middleware),
|
||||
getDefaultMiddleware().concat(
|
||||
pokedexApi.middleware,
|
||||
listenerMiddleware.middleware,
|
||||
),
|
||||
devTools: true,
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue