Skip to content

Workspace.on('active-leaf-change') method

Workspace › on(‘active-leaf-change’)

Official

Triggered when the active leaf changes.

Signature:

on(name: "active-leaf-change", callback: (leaf: WorkspaceLeaf | null) => unknown, ctx?: unknown): EventRef

Parameters:

Parameter Type Description
name "active-leaf-change" Should be 'active-leaf-change'.
callback (leaf: WorkspaceLeaf | null) => unknown The callback function.
ctx? unknown The context passed as this to the callback function.

Returns: EventRefThe event reference.

Since: 0.10.9

Example:

app.workspace.on('active-leaf-change', (leaf) => {
console.log(leaf);
});