2013-09-09 15:35:57 +08:00
|
|
|
# power-monitor
|
2013-08-14 15:43:35 -07:00
|
|
|
|
2015-03-26 10:20:31 -05:00
|
|
|
The `power-monitor` module is used to monitor the power state change. You can
|
2015-04-14 21:03:58 -07:00
|
|
|
only use it on the main process. You should not use this module until the `ready`
|
|
|
|
event of `app` module gets emitted.
|
2013-08-14 15:43:35 -07:00
|
|
|
|
|
|
|
An example is:
|
|
|
|
|
|
|
|
```javascript
|
2015-04-14 21:03:58 -07:00
|
|
|
var app = require('app');
|
|
|
|
|
|
|
|
app.on('ready', function() {
|
2015-04-15 08:17:10 -07:00
|
|
|
require('power-monitor').on('suspend', function() {
|
2015-04-14 21:03:58 -07:00
|
|
|
console.log('The system is going to sleep');
|
|
|
|
});
|
2013-08-14 15:43:35 -07:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
## Event: suspend
|
|
|
|
|
|
|
|
Emitted when the system is suspending.
|
|
|
|
|
|
|
|
## Event: resume
|
|
|
|
|
2013-08-29 16:37:51 +02:00
|
|
|
Emitted when system is resuming.
|
2015-04-14 21:03:58 -07:00
|
|
|
|
|
|
|
## Event: on-ac
|
|
|
|
|
|
|
|
Emitted when the system changes to AC power.
|
|
|
|
|
|
|
|
## Event: on-battery
|
|
|
|
|
|
|
|
Emitted when system changes to battery power.
|