Skip to content

ElectronApp.emit method

ElectronApp › emit

Unofficial

Emits the open-url event, as the OS does when the user opens a URL with the application.

Obsidian's main process handles it by calling preventDefault() on the event object and opening the URL, and ignores any URL that does not start with obsidian://. Emitting it from a renderer through remote.app therefore dispatches an obsidian:// URI natively, including one that targets another vault.

Signature:

emit($event: "open-url", openUrlEvent: Pick<ElectronEvent, "preventDefault">, url: string): boolean

Parameters:

ParameterTypeDescription
$event"open-url"
openUrlEventPick<ElectronEvent, "preventDefault">The event object. Obsidian only calls its preventDefault().
urlstringThe URL to open.

Returns: boolean — Whether the event had listeners.


Unofficial

Synchronously calls each of the listeners registered for the event, in the order they were registered.

Signature:

emit($event: string | symbol, args?: unknown[]): boolean

Parameters:

ParameterTypeDescription
$eventstring | symbol
args?unknown[]The arguments passed to the listeners.

Returns: boolean — Whether the event had listeners.