From 378e56e254386a7f1749c368fb9c365cb7188baa Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 14 Apr 2015 21:03:58 -0700 Subject: [PATCH 1/2] Updated documentation for power-monitor Added two undocumented events, added note that must be used after ready event. --- docs/api/power-monitor.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/api/power-monitor.md b/docs/api/power-monitor.md index 5ead769aa34c..9273e13d9a59 100644 --- a/docs/api/power-monitor.md +++ b/docs/api/power-monitor.md @@ -1,13 +1,19 @@ # power-monitor The `power-monitor` module is used to monitor the power state change. You can -only use it on the main process. +only use it on the main process. You should not use this module until the `ready` +event of `app` module gets emitted. An example is: ```javascript -require('power-monitor').on('suspend', function() { - console.log('The system is going to sleep'); +var app = require('app'); +var powerMonitor = require('power-monitor'); + +app.on('ready', function() { + powerMonitor.on('suspend', function() { + console.log('The system is going to sleep'); + }); }); ``` @@ -18,3 +24,11 @@ Emitted when the system is suspending. ## Event: resume Emitted when system is resuming. + +## Event: on-ac + +Emitted when the system changes to AC power. + +## Event: on-battery + +Emitted when system changes to battery power. From 2de9123cfdc7e420af60d4fcae3fc6679c0e0318 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 15 Apr 2015 08:17:10 -0700 Subject: [PATCH 2/2] Update power-monitor.md --- docs/api/power-monitor.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/api/power-monitor.md b/docs/api/power-monitor.md index 9273e13d9a59..4643110f35bb 100644 --- a/docs/api/power-monitor.md +++ b/docs/api/power-monitor.md @@ -8,10 +8,9 @@ An example is: ```javascript var app = require('app'); -var powerMonitor = require('power-monitor'); app.on('ready', function() { - powerMonitor.on('suspend', function() { + require('power-monitor').on('suspend', function() { console.log('The system is going to sleep'); }); });