Suppose you have a URL of the file that you wish to download, but you just cannot use anchor tag willy nilly for cross-domain requests (You ask why? because modern-day browsers only allow downloads from the same domain). We will use ipcMain.on method to listen to the message sent using ipcRenderer. IpcMain is an event emitter that is used in the main process to listen to sync/async messages from the renderer process. We will be using the send method of ipcRenderer to send a message from the renderer process to the main process. It can send synchronous and asynchronous messages to the main process and listen to messages from the main process. IpcRenderer is an event emitter used by Renderer Process (from inside of web pages) to communicate with the Main process. ![]() One of the key difference between running web pages in browser environment and electron is that electron users have the ability to interact with the operating system on a lower level which is restricted from the browsers So the renderer process is that browser window that electron opens up in its environment to render your web page. In chromium it is referred to as the Browser Process, but to avoid confusion with Renderer Process it is renamed to Main Process in Electron.Īs we know that electron is doing nothing but providing a wrapper around a web application to be run like any other application. It is also responsible for creating the App Menus and the renderer process when needed and deemed fit. ![]() The main process is the controller for the application, from the time it is opened to closed. The Main process is commonly the main.js that we define in our package.json as the entry point for our electron app. If you are new to electron, I would suggest you read the explanation below, but if you’re already aware of the basics and have been developing electron apps, you can skip the next section. Below we’ll see how we can achieve this in an electron application.īefore jumping straight to the task at hand please make sure you are aware of these few basic terms that we are going to use while discussing the solution. ![]() ![]() I know that in the world of web applications this seemed a pretty straightforward thing. We have all come across use cases where we want our users to be able to download a file from our application.
0 Comments
Leave a Reply. |