📝 Update API documentation to ES6 [ci skip]
This commit is contained in:
parent
178496afe5
commit
5a9f28e034
28 changed files with 168 additions and 176 deletions
|
@ -14,8 +14,7 @@ similar to Java's [RMI][rmi]. An example of creating a browser window from a
|
|||
renderer process:
|
||||
|
||||
```javascript
|
||||
const remote = require('electron').remote;
|
||||
const BrowserWindow = remote.BrowserWindow;
|
||||
const { BrowserWindow } = require('electron').remote;
|
||||
|
||||
var win = new BrowserWindow({ width: 800, height: 600 });
|
||||
win.loadURL('https://github.com');
|
||||
|
@ -69,26 +68,22 @@ For instance you can't use a function from the renderer process in an
|
|||
|
||||
```javascript
|
||||
// main process mapNumbers.js
|
||||
exports.withRendererCallback = function(mapper) {
|
||||
exports.withRendererCallback = (mapper) => {
|
||||
return [1,2,3].map(mapper);
|
||||
}
|
||||
|
||||
exports.withLocalCallback = function() {
|
||||
return exports.mapNumbers(function(x) {
|
||||
return x + 1;
|
||||
});
|
||||
exports.withLocalCallback = () => {
|
||||
return exports.mapNumbers(x => x + 1);
|
||||
}
|
||||
```
|
||||
|
||||
```javascript
|
||||
// renderer process
|
||||
var mapNumbers = require("remote").require("./mapNumbers");
|
||||
const mapNumbers = require("remote").require("./mapNumbers");
|
||||
|
||||
var withRendererCb = mapNumbers.withRendererCallback(function(x) {
|
||||
return x + 1;
|
||||
})
|
||||
const withRendererCb = mapNumbers.withRendererCallback(x => x + 1);
|
||||
|
||||
var withLocalCb = mapNumbers.withLocalCallback()
|
||||
const withLocalCb = mapNumbers.withLocalCallback()
|
||||
|
||||
console.log(withRendererCb, withLocalCb) // [true, true, true], [2, 3, 4]
|
||||
```
|
||||
|
@ -104,7 +99,7 @@ For example, the following code seems innocent at first glance. It installs a
|
|||
callback for the `close` event on a remote object:
|
||||
|
||||
```javascript
|
||||
remote.getCurrentWindow().on('close', function() {
|
||||
remote.getCurrentWindow().on('close', () => {
|
||||
// blabla...
|
||||
});
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue