refactor: allow requiring modules with no side effects (#17496)
This commit is contained in:
parent
4ee201c56e
commit
7b55ee9d36
10 changed files with 85 additions and 54 deletions
|
@ -4,17 +4,17 @@
|
|||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
You cannot require or use this module until the `ready` event of the `app`
|
||||
|
||||
This module cannot be used until the `ready` event of the `app`
|
||||
module is emitted.
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
const electron = require('electron')
|
||||
const { app } = electron
|
||||
const { app, powerMonitor } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
electron.powerMonitor.on('suspend', () => {
|
||||
powerMonitor.on('suspend', () => {
|
||||
console.log('The system is going to sleep')
|
||||
})
|
||||
})
|
||||
|
@ -59,7 +59,7 @@ Emitted as soon as the systems screen is unlocked.
|
|||
|
||||
The `powerMonitor` module has the following methods:
|
||||
|
||||
#### `powerMonitor.querySystemIdleState(idleThreshold, callback)` _(Deprecated)_
|
||||
### `powerMonitor.querySystemIdleState(idleThreshold, callback)` _(Deprecated)_
|
||||
|
||||
* `idleThreshold` Integer
|
||||
* `callback` Function
|
||||
|
@ -70,14 +70,14 @@ before considered idle. `callback` will be called synchronously on some systems
|
|||
and with an `idleState` argument that describes the system's state. `locked` is
|
||||
available on supported systems only.
|
||||
|
||||
#### `powerMonitor.querySystemIdleTime(callback)` _(Deprecated)_
|
||||
### `powerMonitor.querySystemIdleTime(callback)` _(Deprecated)_
|
||||
|
||||
* `callback` Function
|
||||
* `idleTime` Integer - Idle time in seconds
|
||||
|
||||
Calculate system idle time in seconds.
|
||||
|
||||
#### `powerMonitor.getSystemIdleState(idleThreshold)`
|
||||
### `powerMonitor.getSystemIdleState(idleThreshold)`
|
||||
|
||||
* `idleThreshold` Integer
|
||||
|
||||
|
@ -86,9 +86,8 @@ Returns `String` - The system's current state. Can be `active`, `idle`, `locked`
|
|||
Calculate the system idle state. `idleThreshold` is the amount of time (in seconds)
|
||||
before considered idle. `locked` is available on supported systems only.
|
||||
|
||||
#### `powerMonitor.getSystemIdleTime()`
|
||||
### `powerMonitor.getSystemIdleTime()`
|
||||
|
||||
Returns `Integer` - Idle time in seconds
|
||||
|
||||
Calculate system idle time in seconds.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue