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:

Parameter Type Description
event "lock-screen" The event name.
listener () => void Callback 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:

Parameter Type Description
event "on-ac" The event name.
listener () => void Callback 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:

Parameter Type Description
event "on-battery" The event name.
listener () => void Callback 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:

Parameter Type Description
event "resume" The event name.
listener () => void Callback 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:

Parameter Type Description
event "shutdown" The event name.
listener (event: ElectronEvent) => void Callback 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:

Parameter Type Description
event "suspend" The event name.
listener () => void Callback 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:

Parameter Type Description
event "unlock-screen" The event name.
listener () => void Callback 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:

Parameter Type Description
event "user-did-become-active" The event name.
listener () => void Callback 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:

Parameter Type Description
event "user-did-resign-active" The event name.
listener () => void Callback invoked the next time the event is emitted.

Returns: thisThis PowerMonitor instance. Platform: darwin.