Move IPC listeners to separate classes

This commit is contained in:
Patrick Fic
2020-10-13 19:52:13 -07:00
parent 030f0b7a90
commit c6f424cf5f
5 changed files with 24 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ import SignInPage from "../components/pages/sign-in/sign-in.page";
import client from "../graphql/GraphQLClient";
import { checkUserSession } from "../redux/user/user.actions";
import { selectCurrentUser } from "../redux/user/user.selectors";
import "../ipc/ipc-init";
const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser,

View File

@@ -15,9 +15,7 @@ export function JobsPage() {
ipcRenderer.on("test-success", (event, obj) => {
console.log("Test Success", obj);
});
ipcRenderer.on(ipcTypes.default.filewatcher.startSuccess, (event, obj) => {
console.log(ipcTypes.default.filewatcher.startSuccess, obj);
});
// Cleanup the listener events so that memory leaks are avoided.
return function cleanup() {
ipcRenderer.removeAllListeners(

View File

@@ -0,0 +1,9 @@
import React from 'react'
export default function IpcListeners() {
return (
<div>
</div>
)
}

12
src/ipc/ipc-init.js Normal file
View File

@@ -0,0 +1,12 @@
import ipcTypes from "../ipc.types";
import { store } from "../redux/store";
import { signOutStart } from "../redux/user/user.actions";
const { ipcRenderer } = window.require("electron");
console.log("----Initializing IPC Listeners in React App.");
ipcRenderer.on(ipcTypes.default.filewatcher.startSuccess, (event, obj) => {
console.log(ipcTypes.default.filewatcher.startSuccess, obj);
store.dispatch(signOutStart());
});

View File

@@ -31,3 +31,4 @@ sagaMiddleWare.run(rootSaga);
export const persistor = persistStore(store);
export default { store, persistStore };