Move IPC listeners to separate classes
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
export default function IpcListeners() {
|
||||
return (
|
||||
<div>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
12
src/ipc/ipc-init.js
Normal file
12
src/ipc/ipc-init.js
Normal 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());
|
||||
});
|
||||
@@ -31,3 +31,4 @@ sagaMiddleWare.run(rootSaga);
|
||||
export const persistor = persistStore(store);
|
||||
|
||||
export default { store, persistStore };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user