The main process and rendering process differences and communication in 17-7-20-electron

Source: Internet
Author: User

The usual, the first to spit groove, and then record.

I was educated by my boss for nearly one hours today. Because of the previously automatic update of the module, I think has been completed, but there are some details are not perfect, has been education ~

All things done, after submission close issue!

In electron, the JS file loaded from Package.json Main is the main process, and the page that is load by the main process is the rendering process.

The rendering process can have multiple, and the main process has only one "main.js".

Communication between the main process and the rendering process can be communicated using Ipcmain (master process) and Ipcrenderer (render process), or by using remote modules.

The IPC module is not introduced, nothing more than a send ' ipcxx.send (channel, Arg) ', then a Receive ' Ipcoo.on (channel, function.) '.

Can be sent and received multiple times, but the ipcxx must be different to communicate with each other, using the channel's information name to identify.

The use of remote was just learned today. There are several sub-modules under remote, such as the app module.

Use ' app.xxx = [Some instance class A, B, C] ' in the main process, because instances of some classes can only be performed once (such as the default set of reads, and so on, will cause the file to become chaotic),

So we can use REMOTE.APP.XXX.A in the rendering process to use classes and methods that are instantiated in the main process.

Say one more. In the main process is often to introduce some additional JS files, in those additional JS files using Main.js declared variables, because it is not a JS file, it needs to be global, so that it can be used in other "direct" files.

All Thanks

The main process and rendering process differences and communication in 17-7-20-electron

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.