docs: Document the new style of remote module

This commit is contained in:
Cheng Zhao 2015-11-13 22:34:00 +08:00
parent 94e24abb99
commit 5cacf79bc5
4 changed files with 14 additions and 5 deletions

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

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

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

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