title: How do I seperate ipcMain.on() functions in different file from main.js
body: <p>I'm creating an electron app with vuejs as frontend. How can I create all the ipcMain.on() functions in a separate file from the main.js. I want this for a more clean code structure.</p>
  
  <p>The app has to work offline so I need to store the data in a local database. So when I create an object in the frontend, I send it with ipcMain to the electron side. Electron can then write it to the local database.</p>
  
  <p>I want something like this:</p>
  
  <p>main.js:</p>
  
  <pre><code>import { app, protocol, BrowserWindow } from "electron";
  import {
    createProtocol,
    installVueDevtools
  } from "vue-cli-plugin-electron-builder/lib";
  
  require("./ipcListeners.js");
  </code></pre>
  
  <p>ipcListeners.js:</p>
  
  <pre><code>import { ipcMain } from "electron";
  
  ipcMain.on("asynchronous-message", (event, arg) =&gt; {
    console.log(arg);
    event.reply("asynchronous-reply", "pong");
  });
  
  ipcMain.on("random-message", (event, arg) =&gt; {
    console.log(arg);
    event.reply("random-reply", "random");
  });
  
  </code></pre>
  
  <p>The problem here is that only the first ipcMain.on() functions works but the second,... doesn't</p>