Refactor decode to match existing partner.

This commit is contained in:
Patrick Fic
2025-03-20 13:44:23 -07:00
parent 45209bd9e4
commit 4310b3779a
10 changed files with 83 additions and 7 deletions

View File

@@ -34,4 +34,13 @@ export const { increment, decrement, incrementByAmount } = appSlice.actions;
// Other code such as selectors can use the imported `RootState` type
export const selectCount = (state: RootState): number => state.app.value;
//Async Functions - Thunks
// Define a thunk that dispatches those action creators
const fetchUsers = () => async (dispatch) => {
dispatch(increment());
//Some sort of async action.
dispatch(incrementByAmount(100));
};
export default appSlice.reducer;

View File

@@ -1,8 +1,10 @@
import { configureStore } from "@reduxjs/toolkit";
import logger from "redux-logger";
import appReducer from "./app.slice";
const store = configureStore({
reducer: { app: appReducer },
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(logger),
});
// Infer the `RootState` and `AppDispatch` types from the store itself

View File

@@ -2,7 +2,8 @@ import type { TypedUseSelectorHook } from "react-redux";
import { useDispatch, useSelector, useStore } from "react-redux";
import type { AppDispatch, AppStore, RootState } from "./redux-store";
// Use throughout your app instead of plain `useDispatch` and `useSelector`
//Use these custom hooks to access the Redux store from your component with type safety.
export const useAppDispatch: () => AppDispatch = useDispatch;
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
export const useAppStore: () => AppStore = useStore;

View File

@@ -0,0 +1,12 @@
//Set up all of the IPC handlers.
import ipcTypes from "../../../util/ipcTypes.json";
const ipcRenderer = window.electron.ipcRenderer;
ipcRenderer.on(
ipcTypes.toRenderer.test,
(event: Electron.IpcRendererEvent, arg) => {
console.log("Received test message from main process");
console.log(arg);
}
);