Skip to content

ElectronPowerMonitor.once method

ElectronPowerMonitor › once

Unofficial

Adds a one-time listener for the lock-screen event.

Signature:

once(event: "lock-screen", listener: () => void): this

Parameters:

ParameterTypeDescription
event"lock-screen"The event name.
listener() => voidCallback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance. Platform: darwin,win32.


Unofficial

Adds a one-time listener for the on-ac event.

Signature:

once(event: "on-ac", listener: () => void): this

Parameters:

ParameterTypeDescription
event"on-ac"The event name.
listener() => voidCallback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance. Platform: darwin,win32.


Unofficial

Adds a one-time listener for the on-battery event.

Signature:

once(event: "on-battery", listener: () => void): this

Parameters:

ParameterTypeDescription
event"on-battery"The event name.
listener() => voidCallback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance. Platform: darwin.


Unofficial

Adds a one-time listener for the resume event.

Signature:

once(event: "resume", listener: () => void): this

Parameters:

ParameterTypeDescription
event"resume"The event name.
listener() => voidCallback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance.


Unofficial

Adds a one-time listener for the shutdown event.

Signature:

once(event: "shutdown", listener: (event: ElectronEvent) => void): this

Parameters:

ParameterTypeDescription
event"shutdown"The event name.
listener(event: ElectronEvent) => voidCallback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance. Platform: linux,darwin.


Unofficial

Adds a one-time listener for the suspend event.

Signature:

once(event: "suspend", listener: () => void): this

Parameters:

ParameterTypeDescription
event"suspend"The event name.
listener() => voidCallback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance.


Unofficial

Adds a one-time listener for the unlock-screen event.

Signature:

once(event: "unlock-screen", listener: () => void): this

Parameters:

ParameterTypeDescription
event"unlock-screen"The event name.
listener() => voidCallback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance. Platform: darwin,win32.


Unofficial

Adds a one-time listener for the user-did-become-active event.

Signature:

once(event: "user-did-become-active", listener: () => void): this

Parameters:

ParameterTypeDescription
event"user-did-become-active"The event name.
listener() => voidCallback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance. Platform: darwin.


Unofficial

Adds a one-time listener for the user-did-resign-active event.

Signature:

once(event: "user-did-resign-active", listener: () => void): this

Parameters:

ParameterTypeDescription
event"user-did-resign-active"The event name.
listener() => voidCallback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance. Platform: darwin.