Skip to content

Vault.on('create') method

Vault › on(‘create’)

Official

Called when a file is created. This is also called when the vault is first loaded for each existing file If you do not wish to receive create events on vault load, register your event handler inside Workspace.onLayoutReady.

Signature:

on(name: "create", callback: (file: TAbstractFile) => unknown, ctx?: unknown): EventRef

Parameters:

Parameter Type Description
name "create" Should be 'create'.
callback (file: TAbstractFile) => unknown The callback function.
ctx? unknown The context passed as this to the callback function.

Returns: EventRefThe event reference.

Example:

app.vault.on('create', (file) => {
console.log(file);
});