Electron Projects
上QQ阅读APP看书,第一时间看更新

Introducing editor-event

Let's introduce editor-event so that we can handle messages from Node.js . We need to import an ipcRenderer object from the Electron framework and listen to any channel. In this case, it is going to be editor-event. For the sake of simplicity, let's output the message's content to the browser console:

<script>
const { ipcRenderer } = require('electron');

ipcRenderer.on('editor-event', (event, arg) => {
console.log(arg);
});
</script>

The preceding code listens to the editor-event channel and writes the message to the browser console's output.