]> khamidou — GitHub mirrors - electron.git/commitdiff
docs: Document the new style of remote module
authorCheng Zhao <zcbenz@gmail.com>
Fri, 13 Nov 2015 14:34:00 +0000 (22:34 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 13 Nov 2015 14:34:00 +0000 (22:34 +0800)
docs/api/menu.md
docs/api/remote.md
docs/api/synopsis.md
docs/tutorial/devtools-extension.md

index c947f36d4790e1d380243c2c599891b6e94f6a34..1d819682160b797911c4533195762599b2d9135f 100644 (file)
@@ -17,8 +17,8 @@ the user right clicks the page:
 <!-- index.html -->
 <script>
 const remote = require('electron').remote;
-const Menu = remote.require('electron').Menu;
-const MenuItem = remote.require('electron').MenuItem;
+const Menu = remote.Menu;
+const MenuItem = remote.MenuItem;
 
 var menu = new Menu();
 menu.append(new MenuItem({ label: 'MenuItem1', click: function() { console.log('item 1 clicked'); } }));
index d6aca3ec26174f61a6c754467d5f5fcf11ccd105..2a5881d31ca60999c1acc1a3258bdb59e185ce23 100644 (file)
@@ -13,7 +13,7 @@ renderer process:
 
 ```javascript
 const remote = require('electron').remote;
-const BrowserWindow = remote.require('electron').BrowserWindow;
+const BrowserWindow = remote.BrowserWindow;
 
 var win = new BrowserWindow({ width: 800, height: 600 });
 win.loadURL('https://github.com');
@@ -118,6 +118,15 @@ passed to the main process. This involves cleaning up event handlers, or
 ensuring the main process is explicitly told to deference callbacks that came
 from a renderer process that is exiting.
 
+## Accessing built-in modules in the main process
+
+The built-in modules in the main process are added as getters in the `remote`
+module, so you can use them directly like the `electron` module.
+
+```javascript
+const app = remote.app;
+```
+
 ## Methods
 
 The `remote` module has the following methods:
index 4cacf52cabd70f9bc11e79bc336f6eb458018d0f..fcb7da2c1cd212f8e7bc8b8a4ca9c9513228c9e7 100644 (file)
@@ -38,7 +38,7 @@ extra ability to use node modules:
 <body>
 <script>
   const remote = require('electron').remote;
-  console.log(remote.require('electron').app.getVersion());
+  console.log(remote.app.getVersion());
 </script>
 </body>
 </html>
index 258fb41947ffc1022feba42c21633928a6d53e33..7c7ea7d64a24165e5a8f13d29c7788719713bcce 100644 (file)
@@ -24,7 +24,7 @@ Then you can load the extension in Electron by opening DevTools in any window,
 and running the following code in the DevTools console:
 
 ```javascript
-const BrowserWindow = require('electron').remote.require('electron').BrowserWindow;
+const BrowserWindow = require('electron').remote.BrowserWindow;
 BrowserWindow.addDevToolsExtension('/some-directory/react-devtools/shells/chrome');
 ```