docs: no class inheritance (#47432)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Erick Zhao <ezhao@slack-corp.com>
This commit is contained in:
parent
15e536b14b
commit
47caba64ab
15 changed files with 67 additions and 6 deletions
|
@ -99,6 +99,10 @@ Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
It creates a new `BaseWindow` with native properties as set by the `options`.
|
It creates a new `BaseWindow` with native properties as set by the `options`.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new BaseWindow([options])`
|
### `new BaseWindow([options])`
|
||||||
|
|
||||||
* `options` [BaseWindowConstructorOptions](structures/base-window-options.md?inline) (optional)
|
* `options` [BaseWindowConstructorOptions](structures/base-window-options.md?inline) (optional)
|
||||||
|
|
|
@ -38,6 +38,10 @@ Process: [Main](../glossary.md#main-process)
|
||||||
This module cannot be used until the `ready` event of the `app`
|
This module cannot be used until the `ready` event of the `app`
|
||||||
module is emitted.
|
module is emitted.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
|
@ -150,6 +150,10 @@ Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
It creates a new `BrowserWindow` with native properties as set by the `options`.
|
It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new BrowserWindow([options])`
|
### `new BrowserWindow([options])`
|
||||||
|
|
||||||
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional)
|
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional)
|
||||||
|
|
|
@ -42,6 +42,10 @@ Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
`ImageView` is an [EventEmitter][event-emitter].
|
`ImageView` is an [EventEmitter][event-emitter].
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new ImageView()` _Experimental_
|
### `new ImageView()` _Experimental_
|
||||||
|
|
||||||
Creates an ImageView.
|
Creates an ImageView.
|
||||||
|
|
|
@ -11,6 +11,10 @@ Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
<!-- TODO(samuelmaddock): refactor doc gen to allow generics to reduce duplication -->
|
<!-- TODO(samuelmaddock): refactor doc gen to allow generics to reduce duplication -->
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### Instance Methods
|
### Instance Methods
|
||||||
|
|
||||||
#### `ipcMainServiceWorker.on(channel, listener)`
|
#### `ipcMainServiceWorker.on(channel, listener)`
|
||||||
|
|
|
@ -6,6 +6,10 @@ Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
See [`Menu`](menu.md) for examples.
|
See [`Menu`](menu.md) for examples.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new MenuItem(options)`
|
### `new MenuItem(options)`
|
||||||
|
|
||||||
* `options` Object
|
* `options` Object
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
Process: [Main](../glossary.md#main-process)
|
Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new Menu()`
|
### `new Menu()`
|
||||||
|
|
||||||
Creates a new menu.
|
Creates a new menu.
|
||||||
|
|
|
@ -33,6 +33,10 @@ ipcRenderer.on('port', (e) => {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### Instance Properties
|
### Instance Properties
|
||||||
|
|
||||||
#### `channel.port1`
|
#### `channel.port1`
|
||||||
|
|
|
@ -4,12 +4,9 @@
|
||||||
|
|
||||||
Process: [Main](../glossary.md#main-process)
|
Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
:::info Renderer process notifications
|
> [!NOTE]
|
||||||
|
> If you want to show notifications from a renderer process you should use the
|
||||||
If you want to show notifications from a renderer process you should use the
|
> [web Notifications API](../tutorial/notifications.md)
|
||||||
[web Notifications API](../tutorial/notifications.md)
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
## Class: Notification
|
## Class: Notification
|
||||||
|
|
||||||
|
@ -21,6 +18,10 @@ Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
It creates a new `Notification` with native properties as set by the `options`.
|
It creates a new `Notification` with native properties as set by the `options`.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### Static Methods
|
### Static Methods
|
||||||
|
|
||||||
The `Notification` class has the following static methods:
|
The `Notification` class has the following static methods:
|
||||||
|
|
|
@ -13,6 +13,10 @@ For including the share menu as a submenu of other menus, please use the
|
||||||
|
|
||||||
Process: [Main](../glossary.md#main-process)
|
Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new ShareMenu(sharingItem)`
|
### `new ShareMenu(sharingItem)`
|
||||||
|
|
||||||
* `sharingItem` SharingItem - The item to share.
|
* `sharingItem` SharingItem - The item to share.
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
# TouchBar
|
# TouchBar
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
## Class: TouchBar
|
## Class: TouchBar
|
||||||
|
|
||||||
> Create TouchBar layouts for native macOS applications
|
> Create TouchBar layouts for native macOS applications
|
||||||
|
|
|
@ -25,6 +25,10 @@ app.whenReady().then(() => {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
**Platform Considerations**
|
**Platform Considerations**
|
||||||
|
|
||||||
**Linux**
|
**Linux**
|
||||||
|
|
|
@ -25,6 +25,10 @@ Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
`View` is an [EventEmitter][event-emitter].
|
`View` is an [EventEmitter][event-emitter].
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new View()`
|
### `new View()`
|
||||||
|
|
||||||
Creates a new `View`.
|
Creates a new `View`.
|
||||||
|
|
|
@ -32,6 +32,10 @@ Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
`WebContentsView` is an [EventEmitter][event-emitter].
|
`WebContentsView` is an [EventEmitter][event-emitter].
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new WebContentsView([options])`
|
### `new WebContentsView([options])`
|
||||||
|
|
||||||
* `options` Object (optional)
|
* `options` Object (optional)
|
||||||
|
|
|
@ -152,6 +152,14 @@ The effect is visible only on (some?) LCD screens. Even if you don't see a diffe
|
||||||
|
|
||||||
Notice that just setting the background in the CSS does not have the desired effect.
|
Notice that just setting the background in the CSS does not have the desired effect.
|
||||||
|
|
||||||
|
## Class inheritance does not work with Electron built-in modules
|
||||||
|
|
||||||
|
Electron classes cannot be subclassed with the [`extends`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends)
|
||||||
|
keyword (also known as class inheritance). This feature was never implemented in Electron due
|
||||||
|
to the added complexity it would add to C++/JavaScript interop in Electron's internals.
|
||||||
|
|
||||||
|
For more information, see [electron/electron#23](https://github.com/electron/electron/issues/23).
|
||||||
|
|
||||||
[memory-management]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management
|
[memory-management]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management
|
||||||
[closures]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
|
[closures]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
|
||||||
[storage]: https://developer.mozilla.org/en-US/docs/Web/API/Storage
|
[storage]: https://developer.mozilla.org/en-US/docs/Web/API/Storage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue