Update power-monitor module

This commit is contained in:
Milan Burda
2016-03-25 21:21:53 +01:00
parent 93b00632d4
commit e808d51112
2 changed files with 31 additions and 2 deletions

View File

@@ -478,6 +478,15 @@ app.on('ready', () => {
powerMonitor.on('suspend', () => {
console.log('The system is going to sleep');
});
powerMonitor.on('resume', () => {
console.log('The system has resumed from sleep');
});
powerMonitor.on('on-ac', () => {
console.log('The system changed to AC power')
});
powerMonitor.on('on-battery', () => {
console.log('The system changed to battery power');
});
});
// protocol

View File

@@ -6,7 +6,27 @@
/// <reference path="../node/node.d.ts" />
declare namespace Electron {
/**
* The power-monitor module is used to monitor power state changes.
* You should not use this module until the ready event of the app module is emitted.
*/
interface PowerMonitor extends NodeJS.EventEmitter {
}
/**
* Emitted when the system is suspending.
*/
on(event: 'suspend', listener: Function): this;
/**
* Emitted when system is resuming.
*/
on(event: 'resume', listener: Function): this;
/**
* Emitted when the system changes to AC power.
*/
on(event: 'on-ac', listener: Function): this;
/**
* Emitted when system changes to battery power.
*/
on(event: 'on-battery', listener: Function): this;
on(event: string, listener: Function): this;
}
}