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:

ParameterTypeDescription
event"accessibility-support-changed"The event name.
listener(event: ElectronEvent, accessibilitySupportEnabled: boolean) => voidThe 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:

ParameterTypeDescription
event"activate"The event name.
listener(event: ElectronEvent, hasVisibleWindows: boolean) => voidThe 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:

ParameterTypeDescription
event"activity-was-continued"The event name.
listener(event: ElectronEvent, type: string, userInfo: unknown) => voidThe 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:

ParameterTypeDescription
event"before-quit"The event name.
listener(event: ElectronEvent) => voidThe 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:

ParameterTypeDescription
event"browser-window-blur"The event name.
listener(event: ElectronEvent, window: ElectronBrowserWindow) => voidThe 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:

ParameterTypeDescription
event"browser-window-created"The event name.
listener(event: ElectronEvent, window: ElectronBrowserWindow) => voidThe 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:

ParameterTypeDescription
event"browser-window-focus"The event name.
listener(event: ElectronEvent, window: ElectronBrowserWindow) => voidThe 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:

ParameterTypeDescription
event"certificate-error"The event name.
listener(event: ElectronEvent, webContents: ElectronWebContents, url: string, error: string, certificate: ElectronCertificate, callback: (isTrusted: boolean) => void, isMainFrame: boolean) => voidThe 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:

ParameterTypeDescription
event"child-process-gone"The event name.
listener(event: ElectronEvent, details: ElectronDetails) => voidThe 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:

ParameterTypeDescription
event"continue-activity"The event name.
listener(event: ElectronEvent, type: string, userInfo: unknown, details: ElectronContinueActivityDetails) => voidThe 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:

ParameterTypeDescription
event"continue-activity-error"The event name.
listener(event: ElectronEvent, type: string, error: string) => voidThe 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:

ParameterTypeDescription
event"did-become-active"The event name.
listener(event: ElectronEvent) => voidThe 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:

ParameterTypeDescription
event"first-instance-ack"The event name.
listener(event: ElectronEvent, additionalData: unknown) => voidThe 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:

ParameterTypeDescription
event"gpu-info-update"The event name.
listener(...args: unknown[]) => voidThe 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:

ParameterTypeDescription
event"gpu-process-crashed"The event name.
listener(event: ElectronEvent, killed: boolean) => voidThe 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:

ParameterTypeDescription
event"login"The event name.
listener(event: ElectronEvent, webContents: ElectronWebContents, authenticationResponseDetails: ElectronAuthenticationResponseDetails, authInfo: ElectronAuthInfo, callback: (username?: string | undefined, password?: string | undefined) => void) => voidThe 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:

ParameterTypeDescription
event"new-window-for-tab"The event name.
listener(event: ElectronEvent) => voidThe 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:

ParameterTypeDescription
event"open-file"The event name.
listener(event: ElectronEvent, path: string) => voidThe 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:

ParameterTypeDescription
event"open-url"The event name.
listener(event: ElectronEvent, url: string) => voidThe 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:

ParameterTypeDescription
event"quit"The event name.
listener(event: ElectronEvent, exitCode: number) => voidThe 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:

ParameterTypeDescription
event"ready"The event name.
listener(event: ElectronEvent, launchInfo: ElectronNotificationResponse | Record<string, unknown>) => voidThe 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:

ParameterTypeDescription
event"render-process-gone"The event name.
listener(event: ElectronEvent, webContents: ElectronWebContents, details: ElectronRenderProcessGoneDetails) => voidThe 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:

ParameterTypeDescription
event"renderer-process-crashed"The event name.
listener(event: ElectronEvent, webContents: ElectronWebContents, killed: boolean) => voidThe 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:

ParameterTypeDescription
event"second-instance"The event name.
listener(event: ElectronEvent, argv: string[], workingDirectory: string, additionalData: unknown, ackCallback: unknown) => voidThe 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:

ParameterTypeDescription
event"select-client-certificate"The event name.
listener(event: ElectronEvent, webContents: ElectronWebContents, url: string, certificateList: ElectronCertificate[], callback: (certificate?: ElectronCertificate | undefined) => void) => voidThe 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:

ParameterTypeDescription
event"session-created"The event name.
listener(session: Session) => voidThe 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:

ParameterTypeDescription
event"update-activity-state"The event name.
listener(event: ElectronEvent, type: string, userInfo: unknown) => voidThe 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:

ParameterTypeDescription
event"web-contents-created"The event name.
listener(event: ElectronEvent, webContents: ElectronWebContents) => voidThe 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:

ParameterTypeDescription
event"will-continue-activity"The event name.
listener(event: ElectronEvent, type: string) => voidThe 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:

ParameterTypeDescription
event"will-finish-launching"The event name.
listener(...args: unknown[]) => voidThe 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:

ParameterTypeDescription
event"will-quit"The event name.
listener(event: ElectronEvent) => voidThe 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:

ParameterTypeDescription
event"window-all-closed"The event name.
listener(...args: unknown[]) => voidThe event handler.

Returns: thisThis ElectronApp instance.