Skip to content

ElectronApp.once method

ElectronApp › once

Unofficial

Registers a one-time listener for the accessibility-support-changed event.

Emitted when Chrome's accessibility support changes. macOS and Windows only.

Signature:

once(event: "accessibility-support-changed", listener: (event: ElectronEvent, accessibilitySupportEnabled: boolean) => void): this

Parameters:

Parameter Type Description
event "accessibility-support-changed" The event name.
listener (event: ElectronEvent, accessibilitySupportEnabled: boolean) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the activate event.

Emitted when the application is activated. macOS only.

Signature:

once(event: "activate", listener: (event: ElectronEvent, hasVisibleWindows: boolean) => void): this

Parameters:

Parameter Type Description
event "activate" The event name.
listener (event: ElectronEvent, hasVisibleWindows: boolean) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the activity-was-continued event.

Emitted during Handoff after an activity from this device was successfully resumed on another one. macOS only.

Signature:

once(event: "activity-was-continued", listener: (event: ElectronEvent, type: string, userInfo: unknown) => void): this

Parameters:

Parameter Type Description
event "activity-was-continued" The event name.
listener (event: ElectronEvent, type: string, userInfo: unknown) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the before-quit event.

Emitted before the application starts closing its windows.

Signature:

once(event: "before-quit", listener: (event: ElectronEvent) => void): this

Parameters:

Parameter Type Description
event "before-quit" The event name.
listener (event: ElectronEvent) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the browser-window-blur event.

Emitted when a browserWindow gets blurred.

Signature:

once(event: "browser-window-blur", listener: (event: ElectronEvent, window: ElectronBrowserWindow) => void): this

Parameters:

Parameter Type Description
event "browser-window-blur" The event name.
listener (event: ElectronEvent, window: ElectronBrowserWindow) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the browser-window-created event.

Emitted when a new browserWindow is created.

Signature:

once(event: "browser-window-created", listener: (event: ElectronEvent, window: ElectronBrowserWindow) => void): this

Parameters:

Parameter Type Description
event "browser-window-created" The event name.
listener (event: ElectronEvent, window: ElectronBrowserWindow) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the browser-window-focus event.

Emitted when a browserWindow gets focused.

Signature:

once(event: "browser-window-focus", listener: (event: ElectronEvent, window: ElectronBrowserWindow) => void): this

Parameters:

Parameter Type Description
event "browser-window-focus" The event name.
listener (event: ElectronEvent, window: ElectronBrowserWindow) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the certificate-error event.

Emitted when failed to verify the certificate for a URL.

Signature:

once(event: "certificate-error", listener: (event: ElectronEvent, webContents: ElectronWebContents, url: string, error: string, certificate: ElectronCertificate, callback: (isTrusted: boolean) => void, isMainFrame: boolean) => void): this

Parameters:

Parameter Type Description
event "certificate-error" The event name.
listener (event: ElectronEvent, webContents: ElectronWebContents, url: string, error: string, certificate: ElectronCertificate, callback: (isTrusted: boolean) => void, isMainFrame: boolean) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the child-process-gone event.

Emitted when the child process unexpectedly disappears.

Signature:

once(event: "child-process-gone", listener: (event: ElectronEvent, details: ElectronDetails) => void): this

Parameters:

Parameter Type Description
event "child-process-gone" The event name.
listener (event: ElectronEvent, details: ElectronDetails) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the continue-activity event.

Emitted during Handoff when an activity from a different device wants to be resumed. macOS only.

Signature:

once(event: "continue-activity", listener: (event: ElectronEvent, type: string, userInfo: unknown, details: ElectronContinueActivityDetails) => void): this

Parameters:

Parameter Type Description
event "continue-activity" The event name.
listener (event: ElectronEvent, type: string, userInfo: unknown, details: ElectronContinueActivityDetails) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the continue-activity-error event.

Emitted during Handoff when an activity from a different device fails to be resumed. macOS only.

Signature:

once(event: "continue-activity-error", listener: (event: ElectronEvent, type: string, error: string) => void): this

Parameters:

Parameter Type Description
event "continue-activity-error" The event name.
listener (event: ElectronEvent, type: string, error: string) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

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

Emitted every time the app becomes active. macOS only.

Signature:

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

Parameters:

Parameter Type Description
event "did-become-active" The event name.
listener (event: ElectronEvent) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the first-instance-ack event.

Emitted in the second instance during requestSingleInstanceLock when the first instance calls the ackCallback.

Signature:

once(event: "first-instance-ack", listener: (event: ElectronEvent, additionalData: unknown) => void): this

Parameters:

Parameter Type Description
event "first-instance-ack" The event name.
listener (event: ElectronEvent, additionalData: unknown) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the gpu-info-update event.

Emitted whenever there is a GPU info update.

Signature:

once(event: "gpu-info-update", listener: (...args: unknown[]) => void): this

Parameters:

Parameter Type Description
event "gpu-info-update" The event name.
listener (...args: unknown[]) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the gpu-process-crashed event.

Emitted when the GPU process crashes or is killed.

Signature:

once(event: "gpu-process-crashed", listener: (event: ElectronEvent, killed: boolean) => void): this

Parameters:

Parameter Type Description
event "gpu-process-crashed" The event name.
listener (event: ElectronEvent, killed: boolean) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the login event.

Emitted when webContents wants to do basic auth.

Signature:

once(event: "login", listener: (event: ElectronEvent, webContents: ElectronWebContents, authenticationResponseDetails: ElectronAuthenticationResponseDetails, authInfo: ElectronAuthInfo, callback: (username?: string | undefined, password?: string | undefined) => void) => void): this

Parameters:

Parameter Type Description
event "login" The event name.
listener (event: ElectronEvent, webContents: ElectronWebContents, authenticationResponseDetails: ElectronAuthenticationResponseDetails, authInfo: ElectronAuthInfo, callback: (username?: string | undefined, password?: string | undefined) => void) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the new-window-for-tab event.

Emitted when the user clicks the native macOS new tab button. macOS only.

Signature:

once(event: "new-window-for-tab", listener: (event: ElectronEvent) => void): this

Parameters:

Parameter Type Description
event "new-window-for-tab" The event name.
listener (event: ElectronEvent) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the open-file event.

Emitted when the user wants to open a file with the application. macOS only.

Signature:

once(event: "open-file", listener: (event: ElectronEvent, path: string) => void): this

Parameters:

Parameter Type Description
event "open-file" The event name.
listener (event: ElectronEvent, path: string) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the open-url event.

Emitted when the user wants to open a URL with the application. macOS only.

Signature:

once(event: "open-url", listener: (event: ElectronEvent, url: string) => void): this

Parameters:

Parameter Type Description
event "open-url" The event name.
listener (event: ElectronEvent, url: string) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the quit event.

Emitted when the application is quitting.

Signature:

once(event: "quit", listener: (event: ElectronEvent, exitCode: number) => void): this

Parameters:

Parameter Type Description
event "quit" The event name.
listener (event: ElectronEvent, exitCode: number) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the ready event.

Emitted once, when Electron has finished initializing.

Signature:

once(event: "ready", listener: (event: ElectronEvent, launchInfo: ElectronNotificationResponse | Record<string, unknown>) => void): this

Parameters:

Parameter Type Description
event "ready" The event name.
listener (event: ElectronEvent, launchInfo: ElectronNotificationResponse | Record<string, unknown>) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the render-process-gone event.

Emitted when the renderer process unexpectedly disappears.

Signature:

once(event: "render-process-gone", listener: (event: ElectronEvent, webContents: ElectronWebContents, details: ElectronRenderProcessGoneDetails) => void): this

Parameters:

Parameter Type Description
event "render-process-gone" The event name.
listener (event: ElectronEvent, webContents: ElectronWebContents, details: ElectronRenderProcessGoneDetails) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the renderer-process-crashed event.

Emitted when the renderer process of webContents crashes or is killed.

Signature:

once(event: "renderer-process-crashed", listener: (event: ElectronEvent, webContents: ElectronWebContents, killed: boolean) => void): this

Parameters:

Parameter Type Description
event "renderer-process-crashed" The event name.
listener (event: ElectronEvent, webContents: ElectronWebContents, killed: boolean) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the second-instance event.

Emitted inside the primary instance when a second instance is executed and calls requestSingleInstanceLock.

Signature:

once(event: "second-instance", listener: (event: ElectronEvent, argv: string[], workingDirectory: string, additionalData: unknown, ackCallback: unknown) => void): this

Parameters:

Parameter Type Description
event "second-instance" The event name.
listener (event: ElectronEvent, argv: string[], workingDirectory: string, additionalData: unknown, ackCallback: unknown) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the select-client-certificate event.

Emitted when a client certificate is requested.

Signature:

once(event: "select-client-certificate", listener: (event: ElectronEvent, webContents: ElectronWebContents, url: string, certificateList: ElectronCertificate[], callback: (certificate?: ElectronCertificate | undefined) => void) => void): this

Parameters:

Parameter Type Description
event "select-client-certificate" The event name.
listener (event: ElectronEvent, webContents: ElectronWebContents, url: string, certificateList: ElectronCertificate[], callback: (certificate?: ElectronCertificate | undefined) => void) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the session-created event.

Emitted when Electron has created a new session.

Signature:

once(event: "session-created", listener: (session: Session) => void): this

Parameters:

Parameter Type Description
event "session-created" The event name.
listener (session: Session) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the update-activity-state event.

Emitted when Handoff is about to be resumed on another device. macOS only.

Signature:

once(event: "update-activity-state", listener: (event: ElectronEvent, type: string, userInfo: unknown) => void): this

Parameters:

Parameter Type Description
event "update-activity-state" The event name.
listener (event: ElectronEvent, type: string, userInfo: unknown) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the web-contents-created event.

Emitted when a new webContents is created.

Signature:

once(event: "web-contents-created", listener: (event: ElectronEvent, webContents: ElectronWebContents) => void): this

Parameters:

Parameter Type Description
event "web-contents-created" The event name.
listener (event: ElectronEvent, webContents: ElectronWebContents) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the will-continue-activity event.

Emitted during Handoff before an activity from a different device wants to be resumed. macOS only.

Signature:

once(event: "will-continue-activity", listener: (event: ElectronEvent, type: string) => void): this

Parameters:

Parameter Type Description
event "will-continue-activity" The event name.
listener (event: ElectronEvent, type: string) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the will-finish-launching event.

Emitted when the application has finished basic startup.

Signature:

once(event: "will-finish-launching", listener: (...args: unknown[]) => void): this

Parameters:

Parameter Type Description
event "will-finish-launching" The event name.
listener (...args: unknown[]) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the will-quit event.

Emitted when all windows have been closed and the application will quit.

Signature:

once(event: "will-quit", listener: (event: ElectronEvent) => void): this

Parameters:

Parameter Type Description
event "will-quit" The event name.
listener (event: ElectronEvent) => void The event handler.

Returns: thisThis ElectronApp instance.


Unofficial

Registers a one-time listener for the window-all-closed event.

Emitted when all windows have been closed.

Signature:

once(event: "window-all-closed", listener: (...args: unknown[]) => void): this

Parameters:

Parameter Type Description
event "window-all-closed" The event name.
listener (...args: unknown[]) => void The event handler.

Returns: thisThis ElectronApp instance.