Used to set up action forwarding in the Electron main process. Middleware must be added to both processes to ensure communication works.

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();
});
}

Type Aliases

RedialMainMiddleware

Return value for the main middleware that adheres to the Middleware API and provides a dispose method that can be called to free resources.

Functions

createRedialMainMiddleware

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.