<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for a feature request that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Problem Description</h3>

<p dir="auto">The current ipcRenderer API appears to be similar to the NodeJS EventEmitter API. However, the ipcRenderer docs list neither an <code class="notranslate">addListener()</code> method nor a <code class="notranslate">off()</code> method. The NodeJS EventEmitter API supports both <code class="notranslate">addListener()</code> and <code class="notranslate">removeListener()</code>, as well as respective <code class="notranslate">on()</code> and <code class="notranslate">off()</code> methods which act as aliases.</p>
<p dir="auto">Furthermore, the methods <code class="notranslate">addListener()</code> and <code class="notranslate">off()</code> appear to be callable on ipcRenderer despite being undocumented, and no not throw any errors, leading to additional confusion.</p>
<h3 dir="auto">Proposed Solution</h3>

<p dir="auto">If the <code class="notranslate">addListener()</code> and/or <code class="notranslate">off()</code> methods are already implemented on ipcRenderer, The ipcRenderer documentation should be updated to reflect this. If they are not implemented, they should either be implemented, or alternatively, some warning should be given to developer that they are either not implemented or are deprecated (e.g. via a message in the console).</p>
<p dir="auto">Finally, although it could be argued that the presence of aliased functions in the NodeJS EventEmitter class causes confusion for developers, I would argue that having one function for adding listeners in one style (<code class="notranslate">on</code>) and one function for removing listeners in another style (<code class="notranslate">removeListener</code>) in Electron without clear documentation makes for a far less desirable developer experience.</p>
<h3 dir="auto">Alternatives Considered</h3>

<p dir="auto">If there is really no desire to implement additional/aliased functions (assuming they do not already exist but are undocumented) in the ipcRenderer API, the API should at least be made consistent by implementing either <code class="notranslate">on</code> and <code class="notranslate">off</code> OR <code class="notranslate">addListener</code> and <code class="notranslate">removeListener</code> and not both, and deprecating the function to be removed from the different style with accompanying notices made available to developers.</p>
<h3 dir="auto">Additional Information</h3>

<p dir="auto">I came across this issue/request while trying to debug a weird issue with React and Electron ipcRenderer events. The confusion between styles for adding/removing event listeners has exacerbated time spent debugging this other problem. For more info, see: <a href="https://stackoverflow.com/questions/60158863/spooky-action-at-a-distance-electron-react-useeffect-unable-to-unsubscribe" rel="nofollow">https://stackoverflow.com/questions/60158863/spooky-action-at-a-distance-electron-react-useeffect-unable-to-unsubscribe</a></p>
<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>8.0.3</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>Win 7</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>unknown</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">Relative windows should not been closed when main window is closed.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">Relative windows will be closed when main window is closed.</p>
<h3 dir="auto">To Reproduce</h3>
<ol dir="auto">
<li>Load a page in main window.</li>
<li>Click a link or use js window.open to open a new window.</li>
<li>Close the main window. The new popup window will be closed immediately.</li>
</ol>