klarna / electron-redux

Use redux in the main and browser processes in electron
MIT License
743 stars 94 forks source link

Execute middleware only in Main thread #355

Closed binarybaron closed 2 months ago

binarybaron commented 2 months ago

Is it possible to execute a middleware (for sideeffects) only in the main thread? I'm using the alpha 2.0 branch.

Currently, my store looks like this:

import { configureStore } from '@reduxjs/toolkit';
import { stateSyncEnhancer } from 'electron-redux';
// import...
import alertsSlice from './features/alertsSlice';

export const store = configureStore({
  reducer: {
    // ...
    alerts: alertsSlice,
  },
  enhancers: [stateSyncEnhancer()],
});

export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;

Specifically I want to register a listener middleware to execute some code that can only be execute on the main thread.