Skip to content

Commit e808d51

Browse files
committed
Update power-monitor module
1 parent 93b0063 commit e808d51

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

github-electron/github-electron-main-tests.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,15 @@ app.on('ready', () => {
478478
powerMonitor.on('suspend', () => {
479479
console.log('The system is going to sleep');
480480
});
481+
powerMonitor.on('resume', () => {
482+
console.log('The system has resumed from sleep');
483+
});
484+
powerMonitor.on('on-ac', () => {
485+
console.log('The system changed to AC power')
486+
});
487+
powerMonitor.on('on-battery', () => {
488+
console.log('The system changed to battery power');
489+
});
481490
});
482491

483492
// protocol

github-electron/github-electron.power-monitor.d.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,27 @@
66
/// <reference path="../node/node.d.ts" />
77

88
declare namespace Electron {
9-
9+
/**
10+
* The power-monitor module is used to monitor power state changes.
11+
* You should not use this module until the ready event of the app module is emitted.
12+
*/
1013
interface PowerMonitor extends NodeJS.EventEmitter {
11-
}
14+
/**
15+
* Emitted when the system is suspending.
16+
*/
17+
on(event: 'suspend', listener: Function): this;
18+
/**
19+
* Emitted when system is resuming.
20+
*/
21+
on(event: 'resume', listener: Function): this;
22+
/**
23+
* Emitted when the system changes to AC power.
24+
*/
25+
on(event: 'on-ac', listener: Function): this;
26+
/**
27+
* Emitted when system changes to battery power.
28+
*/
29+
on(event: 'on-battery', listener: Function): this;
30+
on(event: string, listener: Function): this;
31+
}
1232
}

0 commit comments

Comments
 (0)