Optional
hooks: RedialMiddlewareHooksOptional hooks to run before and after the action is forwarded.
Middleware with a dispose
method for cleaning up any IPC event listeners.
import { createRedialMainMiddleware } from "@laserware/redial/main";
import { configureStore, type Store } from "@reduxjs/toolkit";
import { app } from "electron";
import { rootReducer } from "../common/rootReducer";
export function createStore(): Store {
const redialMiddleware = createRedialMainMiddleware();
const store = configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(redialMiddleware),
});
app.on("before-quit", () => {
// Perform cleanup:
redialMiddleware.dispose();
});
}
Creates middleware that forwards dispatched actions to the renderer process to ensure global state is in sync. The optional
hooks
argument allows you to make changes to the action prior to forwarding and after forwarding before passing the action to the next middlewares.