Skip to content

ElectronNotification.once method

ElectronNotification › once

Unofficial

Registers a one-time event listener that is invoked when one of the notification's actions is activated.

Signature:

once($event: "action", listener: ($event: ElectronEvent, index: number) => void): this

Parameters:

ParameterTypeDescription
$event"action"
listener($event: ElectronEvent, index: number) => voidThe event handler receiving the event and the index of the activated action.

Returns: this — This notification instance.


Unofficial

Registers a one-time event listener that is invoked when the notification is clicked by the user.

Signature:

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

Parameters:

ParameterTypeDescription
$event"click"
listener($event: ElectronEvent) => voidThe event handler.

Returns: this — This notification instance.


Unofficial

Registers a one-time event listener that is invoked when the notification is closed by manual intervention from the user.

Signature:

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

Parameters:

ParameterTypeDescription
$event"close"
listener($event: ElectronEvent) => voidThe event handler.

Returns: this — This notification instance.


Unofficial

Registers a one-time event listener that is invoked when an error is encountered while creating and showing the native notification. win32 only.

Signature:

once($event: "failed", listener: ($event: ElectronEvent, error: string) => void): this

Parameters:

ParameterTypeDescription
$event"failed"
listener($event: ElectronEvent, error: string) => voidThe event handler receiving the event and the error encountered during execution of the show() method.

Returns: this — This notification instance.


Unofficial

Registers a one-time event listener that is invoked when the user clicks the "Reply" button on a notification with hasReply: true. darwin only.

Signature:

once($event: "reply", listener: ($event: ElectronEvent, reply: string) => void): this

Parameters:

ParameterTypeDescription
$event"reply"
listener($event: ElectronEvent, reply: string) => voidThe event handler receiving the event and the string the user entered into the inline reply field.

Returns: this — This notification instance.


Unofficial

Registers a one-time event listener that is invoked when the notification is shown to the user.

Signature:

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

Parameters:

ParameterTypeDescription
$event"show"
listener($event: ElectronEvent) => voidThe event handler.

Returns: this — This notification instance.