title: Event listeners in React/Redux in separate file (electron)
body: <p>So I have a React/electron application. Sometimes my <code>main.js</code> file sends some data over, via ipc. Up until now I had my React components send &amp; wait for certain ipc events like so:</p>
  
  <pre><code>constructor(props) {
      super(props);
  
      ipcRenderer.send('sendTranslateRequest', "Bonjour mon amour");
      ipcRenderer.on('receiveTranslateResponse', (evt, arg) =&gt; {
             //... });
  }
  </code></pre>
  
  <p>However, as I am using Redux now I found myself thinking a bit more about my apps architecture. Would it not be a good idea to create a separate file and put all my listeners into it, and whenever a listener is activated, to dispatch a Redux action. And likewise, to put all my <code>ipcRenderer.send</code>s into the respective Redux actions, so that my React Components are completely clear from all of that?</p>
  
  <p>Would this be possible? And: Would this be a good idea?</p>
  
  <p>I am wondering how I could create a file which has the ability to take all my listeners. So I would have a file like this:</p>
  
  <pre><code>ipcRenderer.on('receiveTranslateResponse', (evt, arg) =&gt; {
      //dispatch actions then
      });
  ipcRenderer.on('receiveAnotherResponse', (evt, arg) =&gt; {
      //dispatch actions then
      });
  </code></pre>
  
  <p>What I don't understand is how I could include this file into my React application, how &amp; where to execute it?</p>