@laserware/redial
    Preparing search index...

    Module main

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

    Interfaces

    RedialMiddlewareHooks

    Hooks that run before and after the action are sent from one process to another. This is useful for doing things like ensuring the payload is serialized before sending the action, or making a change to the action after it's sent to the renderer process.

    Type Aliases

    RedialAction

    Redux action with additional metadata to indicate if the action was already forwarded from the other process.

    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 the 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.