<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[`Workspace`](Workspace) › [on('file-open')](Workspace/on('file-open').md)
## Workspace.on('file-open') method
Triggered when the active file changes. The file could be in a new leaf, an existing leaf, or an embed.
**Signature:**
```typescript
on(name: 'file-open', callback: (file: TFile | null) => any, ctx?: any): EventRef;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| <code>name</code> | <code>'file-open'</code> | |
| <code>callback</code> | <code>(file: </code>[`TFile`](TFile)<code> | null) => any</code> | |
| <code>ctx</code> | <code>any</code> | _(Optional)_ |
**Returns:**
[`EventRef`](EventRef)