Adding in changes
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
export * from './store';
|
||||
export * from './slices';
|
||||
@@ -0,0 +1,10 @@
|
||||
/* Core */
|
||||
import { pagesApi } from '@/services/pages'
|
||||
import { postsApi } from '@/services/posts'
|
||||
|
||||
const middleware = [
|
||||
postsApi.middleware,
|
||||
pagesApi.middleware,
|
||||
]
|
||||
|
||||
export { middleware }
|
||||
@@ -0,0 +1,7 @@
|
||||
import { pagesApi } from "@/services/pages";
|
||||
import { postsApi } from "@/services/posts";
|
||||
|
||||
export const reducer = {
|
||||
[postsApi.reducerPath]: postsApi.reducer,
|
||||
[pagesApi.reducerPath]: pagesApi.reducer,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * from './selectors';
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Instruments */
|
||||
import type { ReduxState } from '@/lib/redux';
|
||||
|
||||
export const selectCount = (state: ReduxState) => state.counter.value;
|
||||
@@ -0,0 +1,30 @@
|
||||
/* Core */
|
||||
import { configureStore, type ThunkAction, type Action } from "@reduxjs/toolkit";
|
||||
import {
|
||||
useSelector as useReduxSelector,
|
||||
useDispatch as useReduxDispatch,
|
||||
type TypedUseSelectorHook,
|
||||
} from "react-redux";
|
||||
import { createWrapper } from "next-redux-wrapper";
|
||||
|
||||
/* Instruments */
|
||||
import { reducer } from './rootReducer';
|
||||
import { middleware } from './middleware';
|
||||
|
||||
export const reduxStore = () => configureStore({
|
||||
reducer,
|
||||
middleware: (getDefaultMiddleware) => {
|
||||
return getDefaultMiddleware().concat(middleware);
|
||||
}
|
||||
});
|
||||
|
||||
/* Types */
|
||||
export type ReduxStore = ReturnType<typeof reduxStore>;
|
||||
export type ReduxState = ReturnType<ReduxStore['getState']>;
|
||||
export type ReduxDispatch = ReduxStore['dispatch'];
|
||||
export type ReduxThunkAction<ReturnType = void> = ThunkAction<ReturnType, ReduxState, unknown, Action>;
|
||||
|
||||
export const useDispatch = () => useReduxDispatch<ReduxDispatch>();
|
||||
export const useSelector: TypedUseSelectorHook<ReduxState> = useReduxSelector;
|
||||
|
||||
export const wrapper = createWrapper<ReduxStore>(reduxStore);
|
||||
Reference in New Issue
Block a user