ElectronApp.once method
ElectronApp › once
Unofficial
Registers a one-time listener for theaccessibility-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "accessibility-support-changed" | The event name. |
| listener | (event: ElectronEvent, accessibilitySupportEnabled: boolean) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for theactivate event.Emitted when the application is activated. macOS only.
Signature:
once(event: "activate", listener: (event: ElectronEvent, hasVisibleWindows: boolean) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "activate" | The event name. |
| listener | (event: ElectronEvent, hasVisibleWindows: boolean) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for theactivity-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "activity-was-continued" | The event name. |
| listener | (event: ElectronEvent, type: string, userInfo: unknown) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thebefore-quit event.Emitted before the application starts closing its windows.
Signature:
once(event: "before-quit", listener: (event: ElectronEvent) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "before-quit" | The event name. |
| listener | (event: ElectronEvent) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thebrowser-window-blur event.Emitted when a browserWindow gets blurred.
Signature:
once(event: "browser-window-blur", listener: (event: ElectronEvent, window: ElectronBrowserWindow) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "browser-window-blur" | The event name. |
| listener | (event: ElectronEvent, window: ElectronBrowserWindow) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thebrowser-window-created event.Emitted when a new browserWindow is created.
Signature:
once(event: "browser-window-created", listener: (event: ElectronEvent, window: ElectronBrowserWindow) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "browser-window-created" | The event name. |
| listener | (event: ElectronEvent, window: ElectronBrowserWindow) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thebrowser-window-focus event.Emitted when a browserWindow gets focused.
Signature:
once(event: "browser-window-focus", listener: (event: ElectronEvent, window: ElectronBrowserWindow) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "browser-window-focus" | The event name. |
| listener | (event: ElectronEvent, window: ElectronBrowserWindow) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thecertificate-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): thisParameters:
| 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: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thechild-process-gone event.Emitted when the child process unexpectedly disappears.
Signature:
once(event: "child-process-gone", listener: (event: ElectronEvent, details: ElectronDetails) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "child-process-gone" | The event name. |
| listener | (event: ElectronEvent, details: ElectronDetails) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thecontinue-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "continue-activity" | The event name. |
| listener | (event: ElectronEvent, type: string, userInfo: unknown, details: ElectronContinueActivityDetails) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thecontinue-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "continue-activity-error" | The event name. |
| listener | (event: ElectronEvent, type: string, error: string) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thedid-become-active event.Emitted every time the app becomes active. macOS only.
Signature:
once(event: "did-become-active", listener: (event: ElectronEvent) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "did-become-active" | The event name. |
| listener | (event: ElectronEvent) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thefirst-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "first-instance-ack" | The event name. |
| listener | (event: ElectronEvent, additionalData: unknown) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thegpu-info-update event.Emitted whenever there is a GPU info update.
Signature:
once(event: "gpu-info-update", listener: (...args: unknown[]) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "gpu-info-update" | The event name. |
| listener | (...args: unknown[]) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thegpu-process-crashed event.Emitted when the GPU process crashes or is killed.
Signature:
once(event: "gpu-process-crashed", listener: (event: ElectronEvent, killed: boolean) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "gpu-process-crashed" | The event name. |
| listener | (event: ElectronEvent, killed: boolean) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thelogin 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): thisParameters:
| 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: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thenew-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "new-window-for-tab" | The event name. |
| listener | (event: ElectronEvent) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for theopen-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "open-file" | The event name. |
| listener | (event: ElectronEvent, path: string) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for theopen-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "open-url" | The event name. |
| listener | (event: ElectronEvent, url: string) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thequit event.Emitted when the application is quitting.
Signature:
once(event: "quit", listener: (event: ElectronEvent, exitCode: number) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "quit" | The event name. |
| listener | (event: ElectronEvent, exitCode: number) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for theready event.Emitted once, when Electron has finished initializing.
Signature:
once(event: "ready", listener: (event: ElectronEvent, launchInfo: ElectronNotificationResponse | Record<string, unknown>) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "ready" | The event name. |
| listener | (event: ElectronEvent, launchInfo: ElectronNotificationResponse | Record<string, unknown>) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for therender-process-gone event.Emitted when the renderer process unexpectedly disappears.
Signature:
once(event: "render-process-gone", listener: (event: ElectronEvent, webContents: ElectronWebContents, details: ElectronRenderProcessGoneDetails) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "render-process-gone" | The event name. |
| listener | (event: ElectronEvent, webContents: ElectronWebContents, details: ElectronRenderProcessGoneDetails) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for therenderer-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "renderer-process-crashed" | The event name. |
| listener | (event: ElectronEvent, webContents: ElectronWebContents, killed: boolean) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thesecond-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): thisParameters:
| 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: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for theselect-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): thisParameters:
| 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: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thesession-created event.Emitted when Electron has created a new
session. Signature:
once(event: "session-created", listener: (session: Session) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "session-created" | The event name. |
| listener | (session: Session) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for theupdate-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "update-activity-state" | The event name. |
| listener | (event: ElectronEvent, type: string, userInfo: unknown) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for theweb-contents-created event.Emitted when a new
webContents is created. Signature:
once(event: "web-contents-created", listener: (event: ElectronEvent, webContents: ElectronWebContents) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "web-contents-created" | The event name. |
| listener | (event: ElectronEvent, webContents: ElectronWebContents) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thewill-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): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "will-continue-activity" | The event name. |
| listener | (event: ElectronEvent, type: string) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thewill-finish-launching event.Emitted when the application has finished basic startup.
Signature:
once(event: "will-finish-launching", listener: (...args: unknown[]) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "will-finish-launching" | The event name. |
| listener | (...args: unknown[]) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thewill-quit event.Emitted when all windows have been closed and the application will quit.
Signature:
once(event: "will-quit", listener: (event: ElectronEvent) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "will-quit" | The event name. |
| listener | (event: ElectronEvent) => void | The event handler. |
Returns: this — This ElectronApp instance.
Unofficial
Registers a one-time listener for thewindow-all-closed event.Emitted when all windows have been closed.
Signature:
once(event: "window-all-closed", listener: (...args: unknown[]) => void): thisParameters:
| Parameter | Type | Description |
|---|---|---|
| event | "window-all-closed" | The event name. |
| listener | (...args: unknown[]) => void | The event handler. |
Returns: this — This ElectronApp instance.