Browse Source

docs: Document the new style of remote module

Cheng Zhao 9 years ago
parent
commit
5cacf79bc5
4 changed files with 14 additions and 5 deletions
  1. 2 2
      docs/api/menu.md
  2. 10 1
      docs/api/remote.md
  3. 1 1
      docs/api/synopsis.md
  4. 1 1
      docs/tutorial/devtools-extension.md

+ 2 - 2
docs/api/menu.md

@@ -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'); } }));

+ 10 - 1
docs/api/remote.md

@@ -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:

+ 1 - 1
docs/api/synopsis.md

@@ -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>

+ 1 - 1
docs/tutorial/devtools-extension.md

@@ -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');
 ```