[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F8B6H7KA88E45QRX22S4A3":3,"skill-same:01M6F8B6H7KA88E45QRX22S4A3":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":6,"ownerHtmlUrl":57,"ownerBlogUrl":58,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M6F8B6H7KA88E45QRX22S4A3","obsidian-webhooks-events",null,"Handle Obsidian events and workspace callbacks for plugin development.\nUse when implementing reactive features, handling file changes,\nor responding to user interactions in your plugin.\nTrigger with phrases like \"obsidian events\", \"obsidian callbacks\",\n\"obsidian file change\", \"obsidian workspace events\".","Dicklesworthstone\u002Fpi_agent_rust","Dicklesworthstone","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F35050222?v=4","01M6CG26AR942CSVMN1M5E3DSE","Jeff Emanuel","01M6CG26EPP71PSHW1VDS71121",1992,"MIT","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Fplugins-community\u002Fplugins\u002Fsaas-packs\u002Fobsidian-pack\u002Fskills\u002Fobsidian-webhooks-events\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"obsidian webhooks events","events","webhooks","obsidian","io","when","reactive","features","for","implementing","plugin development","with","Callbacks","trigger","use","user","edit","write","read","workspace","file","development","plugin","change","2026-11-10 10:12:30",false,"---\nname: obsidian-webhooks-events\ndescription: |\n  Handle Obsidian events and workspace callbacks for plugin development.\n  Use when implementing reactive features, handling file changes,\n  or responding to user interactions in your plugin.\n  Trigger with phrases like \"obsidian events\", \"obsidian callbacks\",\n  \"obsidian file change\", \"obsidian workspace events\".\nallowed-tools: Read, Write, Edit\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\n---\n\n# Obsidian Webhooks & Events\n\n## Overview\nComprehensive guide to handling events in Obsidian plugins - workspace events, vault events, and custom event patterns.\n\n## Prerequisites\n- Understanding of Obsidian plugin lifecycle\n- Familiarity with TypeScript event patterns\n- Basic plugin setup completed\n\n## Event Categories\n\n### Available Events\n| Category | Events | Use Case |\n|----------|--------|----------|\n| Workspace | file-open, active-leaf-change, layout-change | UI state changes |\n| Vault | create, modify, delete, rename | File system changes |\n| MetadataCache | changed, resolved | Metadata\u002Flink updates |\n| Editor | change, cursor-activity | Text editing |\n\n## Instructions\n\n### Step 1: Workspace Events\n```typescript\nimport { Plugin, TFile, WorkspaceLeaf } from 'obsidian';\n\nexport default class MyPlugin extends Plugin {\n  async onload() {\n    \u002F\u002F File opened in editor\n    this.registerEvent(\n      this.app.workspace.on('file-open', (file: TFile | null) => {\n        if (file) {\n          console.log('Opened file:', file.path);\n          this.onFileOpen(file);\n        }\n      })\n    );\n\n    \u002F\u002F Active leaf (pane) changed\n    this.registerEvent(\n      this.app.workspace.on('active-leaf-change', (leaf: WorkspaceLeaf | null) => {\n        if (leaf) {\n          console.log('Active leaf changed:', leaf.view.getViewType());\n        }\n      })\n    );\n\n    \u002F\u002F Layout changed (panes rearranged)\n    this.registerEvent(\n      this.app.workspace.on('layout-change', () => {\n        console.log('Layout changed');\n        this.onLayoutChange();\n      })\n    );\n\n    \u002F\u002F Editor mode changed (source\u002Fpreview)\n    this.registerEvent(\n      this.app.workspace.on('layout-change', () => {\n        const view = this.app.workspace.getActiveViewOfType(MarkdownView);\n        if (view) {\n          const mode = view.getMode(); \u002F\u002F 'source' or 'preview'\n          console.log('Editor mode:', mode);\n        }\n      })\n    );\n\n    \u002F\u002F Window focus\n    this.registerEvent(\n      this.app.workspace.on('window-open', (win, window) => {\n        console.log('New window opened');\n      })\n    );\n  }\n\n  private onFileOpen(file: TFile) {\n    \u002F\u002F React to file opening\n  }\n\n  private onLayoutChange() {\n    \u002F\u002F React to layout changes\n  }\n}\n```\n\n### Step 2: Vault Events\n```typescript\nimport { Plugin, TFile, TFolder, TAbstractFile } from 'obsidian';\n\nexport default class MyPlugin extends Plugin {\n  async onload() {\n    \u002F\u002F File created\n    this.registerEvent(\n      this.app.vault.on('create', (file: TAbstractFile) => {\n        if (file instanceof TFile) {\n          console.log('File created:', file.path);\n          this.onFileCreated(file);\n        } else if (file instanceof TFolder) {\n          console.log('Folder created:', file.path);\n        }\n      })\n    );\n\n    \u002F\u002F File modified\n    this.registerEvent(\n      this.app.vault.on('modify', (file: TAbstractFile) => {\n        if (file instanceof TFile) {\n          console.log('File modified:', file.path);\n          this.onFileModified(file);\n        }\n      })\n    );\n\n    \u002F\u002F File deleted\n    this.registerEvent(\n      this.app.vault.on('delete', (file: TAbstractFile) => {\n        console.log('File deleted:', file.path);\n        this.onFileDeleted(file);\n      })\n    );\n\n    \u002F\u002F File renamed\u002Fmoved\n    this.registerEvent(\n      this.app.vault.on('rename', (file: TAbstractFile, oldPath: string) => {\n        console.log(`File renamed: ${oldPath} -> ${file.path}`);\n        this.onFileRenamed(file, oldPath);\n      })\n    );\n  }\n\n  private onFileCreated(file: TFile) {\n    \u002F\u002F Apply template, add frontmatter, etc.\n  }\n\n  private onFileModified(file: TFile) {\n    \u002F\u002F Update indexes, trigger sync, etc.\n  }\n\n  private onFileDeleted(file: TAbstractFile) {\n    \u002F\u002F Clean up references, update cache, etc.\n  }\n\n  private onFileRenamed(file: TAbstractFile, oldPath: string) {\n    \u002F\u002F Update links, references, etc.\n  }\n}\n```\n\n### Step 3: MetadataCache Events\n```typescript\nimport { Plugin, TFile, CachedMetadata } from 'obsidian';\n\nexport default class MyPlugin extends Plugin {\n  async onload() {\n    \u002F\u002F Metadata changed for a file\n    this.registerEvent(\n      this.app.metadataCache.on('changed', (file: TFile, data: string, cache: CachedMetadata) => {\n        console.log('Metadata changed:', file.path);\n\n        \u002F\u002F Access frontmatter\n        if (cache.frontmatter) {\n          console.log('Frontmatter:', cache.frontmatter);\n        }\n\n        \u002F\u002F Access tags\n        if (cache.tags) {\n          const tags = cache.tags.map(t => t.tag);\n          console.log('Tags:', tags);\n        }\n\n        \u002F\u002F Access links\n        if (cache.links) {\n          const links = cache.links.map(l => l.link);\n          console.log('Links:', links);\n        }\n      })\n    );\n\n    \u002F\u002F All files resolved (vault fully loaded)\n    this.registerEvent(\n      this.app.metadataCache.on('resolved', () => {\n        console.log('All files resolved - vault fully loaded');\n        this.onVaultReady();\n      })\n    );\n  }\n\n  private onVaultReady() {\n    \u002F\u002F Safe to do full vault operations\n    const allFiles = this.app.vault.getMarkdownFiles();\n    console.log(`Vault ready with ${allFiles.length} files`);\n  }\n}\n```\n\n### Step 4: Debounced Event Handling\n```typescript\n\u002F\u002F src\u002Futils\u002Fdebounced-events.ts\nimport { Plugin, TFile } from 'obsidian';\n\nexport class DebouncedEventHandler {\n  private modifyTimeout: Map\u003Cstring, NodeJS.Timeout> = new Map();\n  private debounceMs: number;\n  private handler: (file: TFile) => void;\n\n  constructor(debounceMs: number, handler: (file: TFile) => void) {\n    this.debounceMs = debounceMs;\n    this.handler = handler;\n  }\n\n  handleModify(file: TFile) {\n    \u002F\u002F Clear existing timeout for this file\n    const existing = this.modifyTimeout.get(file.path);\n    if (existing) {\n      clearTimeout(existing);\n    }\n\n    \u002F\u002F Set new debounced timeout\n    const timeout = setTimeout(() => {\n      this.modifyTimeout.delete(file.path);\n      this.handler(file);\n    }, this.debounceMs);\n\n    this.modifyTimeout.set(file.path, timeout);\n  }\n\n  cleanup() {\n    \u002F\u002F Clear all pending timeouts\n    for (const timeout of this.modifyTimeout.values()) {\n      clearTimeout(timeout);\n    }\n    this.modifyTimeout.clear();\n  }\n}\n\n\u002F\u002F Usage in plugin:\nexport default class MyPlugin extends Plugin {\n  private debouncedHandler: DebouncedEventHandler;\n\n  async onload() {\n    this.debouncedHandler = new DebouncedEventHandler(\n      1000, \u002F\u002F 1 second debounce\n      (file) => this.processFileChange(file)\n    );\n\n    this.registerEvent(\n      this.app.vault.on('modify', (file) => {\n        if (file instanceof TFile) {\n          this.debouncedHandler.handleModify(file);\n        }\n      })\n    );\n  }\n\n  onunload() {\n    this.debouncedHandler.cleanup();\n  }\n\n  private processFileChange(file: TFile) {\n    \u002F\u002F Handle the debounced file change\n    console.log('Processing change for:', file.path);\n  }\n}\n```\n\n### Step 5: Custom Event Emitter\n```typescript\n\u002F\u002F src\u002Fevents\u002Fevent-bus.ts\nimport { Events } from 'obsidian';\n\n\u002F\u002F Define custom events\ninterface MyPluginEvents {\n  'index-updated': (count: number) => void;\n  'sync-complete': (success: boolean, error?: string) => void;\n  'settings-changed': (key: string, value: any) => void;\n}\n\nexport class PluginEventBus extends Events {\n  on\u003CK extends keyof MyPluginEvents>(\n    event: K,\n    callback: MyPluginEvents[K],\n    ctx?: any\n  ): EventRef {\n    return super.on(event as string, callback, ctx);\n  }\n\n  off\u003CK extends keyof MyPluginEvents>(\n    event: K,\n    callback: MyPluginEvents[K]\n  ): void {\n    super.off(event as string, callback);\n  }\n\n  trigger\u003CK extends keyof MyPluginEvents>(\n    event: K,\n    ...args: Parameters\u003CMyPluginEvents[K]>\n  ): void {\n    super.trigger(event as string, ...args);\n  }\n}\n\n\u002F\u002F Usage:\nconst eventBus = new PluginEventBus();\n\n\u002F\u002F Subscribe\neventBus.on('index-updated', (count) => {\n  console.log(`Index updated with ${count} items`);\n});\n\n\u002F\u002F Emit\neventBus.trigger('index-updated', 42);\n```\n\n### Step 6: File Watcher Pattern\n```typescript\n\u002F\u002F src\u002Fwatchers\u002Ffile-watcher.ts\nimport { Plugin, TFile } from 'obsidian';\n\ninterface WatchConfig {\n  folder?: string;\n  extension?: string;\n  includePattern?: RegExp;\n  excludePattern?: RegExp;\n}\n\nexport class FileWatcher {\n  private plugin: Plugin;\n  private config: WatchConfig;\n  private callbacks: {\n    onCreate?: (file: TFile) => void;\n    onModify?: (file: TFile) => void;\n    onDelete?: (path: string) => void;\n    onRename?: (file: TFile, oldPath: string) => void;\n  };\n\n  constructor(\n    plugin: Plugin,\n    config: WatchConfig,\n    callbacks: typeof FileWatcher.prototype.callbacks\n  ) {\n    this.plugin = plugin;\n    this.config = config;\n    this.callbacks = callbacks;\n    this.register();\n  }\n\n  private shouldWatch(path: string): boolean {\n    if (this.config.folder && !path.startsWith(this.config.folder)) {\n      return false;\n    }\n    if (this.config.extension && !path.endsWith(this.config.extension)) {\n      return false;\n    }\n    if (this.config.includePattern && !this.config.includePattern.test(path)) {\n      return false;\n    }\n    if (this.config.excludePattern && this.config.excludePattern.test(path)) {\n      return false;\n    }\n    return true;\n  }\n\n  private register() {\n    if (this.callbacks.onCreate) {\n      this.plugin.registerEvent(\n        this.plugin.app.vault.on('create', (file) => {\n          if (file instanceof TFile && this.shouldWatch(file.path)) {\n            this.callbacks.onCreate!(file);\n          }\n        })\n      );\n    }\n\n    if (this.callbacks.onModify) {\n      this.plugin.registerEvent(\n        this.plugin.app.vault.on('modify', (file) => {\n          if (file instanceof TFile && this.shouldWatch(file.path)) {\n            this.callbacks.onModify!(file);\n          }\n        })\n      );\n    }\n\n    if (this.callbacks.onDelete) {\n      this.plugin.registerEvent(\n        this.plugin.app.vault.on('delete', (file) => {\n          if (this.shouldWatch(file.path)) {\n            this.callbacks.onDelete!(file.path);\n          }\n        })\n      );\n    }\n\n    if (this.callbacks.onRename) {\n      this.plugin.registerEvent(\n        this.plugin.app.vault.on('rename', (file, oldPath) => {\n          if (file instanceof TFile && (this.shouldWatch(file.path) || this.shouldWatch(oldPath))) {\n            this.callbacks.onRename!(file, oldPath);\n          }\n        })\n      );\n    }\n  }\n}\n\n\u002F\u002F Usage:\nnew FileWatcher(\n  this,\n  {\n    folder: 'journal\u002F',\n    extension: '.md',\n    excludePattern: \u002Ftemplate\u002Fi,\n  },\n  {\n    onCreate: (file) => console.log('Journal created:', file.path),\n    onModify: (file) => console.log('Journal modified:', file.path),\n  }\n);\n```\n\n## Output\n- Workspace event handlers for UI state\n- Vault event handlers for file operations\n- MetadataCache handlers for content changes\n- Debounced handlers for frequent events\n- Custom event bus for internal communication\n- Filtered file watchers\n\n## Error Handling\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| Memory leak | Unregistered events | Use `registerEvent` |\n| Performance issues | Too many handlers | Debounce frequent events |\n| Missed events | Late registration | Register in `onload` |\n| Stale data | Cache not updated | Use `metadataCache.on('changed')` |\n\n## Examples\n\n### Complete Event-Driven Plugin\n```typescript\nexport default class MyPlugin extends Plugin {\n  async onload() {\n    \u002F\u002F Wait for vault to be ready\n    this.app.workspace.onLayoutReady(() => {\n      this.initializeAfterVaultReady();\n    });\n  }\n\n  private initializeAfterVaultReady() {\n    \u002F\u002F Now safe to access all files\n    this.buildInitialIndex();\n    this.registerAllEvents();\n  }\n\n  private registerAllEvents() {\n    \u002F\u002F File events\n    this.registerEvent(\n      this.app.vault.on('modify', this.handleModify.bind(this))\n    );\n\n    \u002F\u002F Workspace events\n    this.registerEvent(\n      this.app.workspace.on('file-open', this.handleFileOpen.bind(this))\n    );\n  }\n\n  private handleModify(file: TAbstractFile) {\n    if (file instanceof TFile) {\n      \u002F\u002F Update index\n    }\n  }\n\n  private handleFileOpen(file: TFile | null) {\n    if (file) {\n      \u002F\u002F Track recently opened\n    }\n  }\n}\n```\n\n## Resources\n- [Obsidian Events API](https:\u002F\u002Fdocs.obsidian.md\u002FReference\u002FTypeScript+API\u002FEvents)\n- [Workspace Events](https:\u002F\u002Fdocs.obsidian.md\u002FReference\u002FTypeScript+API\u002FWorkspace)\n- [Vault Events](https:\u002F\u002Fdocs.obsidian.md\u002FReference\u002FTypeScript+API\u002FVault)\n\n## Next Steps\nFor performance optimization, see `obsidian-performance-tuning`.\n","# Obsidian Webhooks & Events\n\n## Overview\nComprehensive guide to handling events in Obsidian plugins - workspace events, vault events, and custom event patterns.\n\n## Prerequisites\n- Understanding of Obsidian plugin lifecycle\n- Familiarity with TypeScript event patterns\n- Basic plugin setup completed\n\n## Event Categories\n\n### Available Events\n| Category | Events | Use Case |\n|----------|--------|----------|\n| Workspace | file-open, active-leaf-change, layout-change | UI state changes |\n| Vault | create, modify, delete, rename | File system changes |\n| MetadataCache | changed, resolved | Metadata\u002Flink updates |\n| Editor | change, cursor-activity | Text editing |\n\n## Instructions\n\n### Step 1: Workspace Events\n```typescript\nimport { Plugin, TFile, WorkspaceLeaf } from 'obsidian';\n\nexport default class MyPlugin extends Plugin {\n  async onload() {\n    \u002F\u002F File opened in editor\n    this.registerEvent(\n      this.app.workspace.on('file-open', (file: TFile | null) => {\n        if (file) {\n          console.log('Opened file:', file.path);\n          this.onFileOpen(file);\n        }\n      })\n    );\n\n    \u002F\u002F Active leaf (pane) changed\n    this.registerEvent(\n      this.app.workspace.on('active-leaf-change', (leaf: WorkspaceLeaf | null) => {\n        if (leaf) {\n          console.log('Active leaf changed:', leaf.view.getViewType());\n        }\n      })\n    );\n\n    \u002F\u002F Layout changed (panes rearranged)\n    this.registerEvent(\n      this.app.workspace.on('layout-change', () => {\n        console.log('Layout changed');\n        this.onLayoutChange();\n      })\n    );\n\n    \u002F\u002F Editor mode changed (source\u002Fpreview)\n    this.registerEvent(\n      this.app.workspace.on('layout-change', () => {\n        const view = this.app.workspace.getActiveViewOfType(MarkdownView);\n        if (view) {\n          const mode = view.getMode(); \u002F\u002F 'source' or 'preview'\n          console.log('Editor mode:', mode);\n        }\n      })\n    );\n\n    \u002F\u002F Window focus\n    this.registerEvent(\n      this.app.workspace.on('window-open', (win, window) => {\n        console.log('New window opened');\n      })\n    );\n  }\n\n  private onFileOpen(file: TFile) {\n    \u002F\u002F React to file opening\n  }\n\n  private onLayoutChange() {\n    \u002F\u002F React to layout changes\n  }\n}\n```\n\n### Step 2: Vault Events\n```typescript\nimport { Plugin, TFile, TFolder, TAbstractFile } from 'obsidian';\n\nexport default class MyPlugin extends Plugin {\n  async onload() {\n    \u002F\u002F File created\n    this.registerEvent(\n      this.app.vault.on('create', (file: TAbstractFile) => {\n        if (file instanceof TFile) {\n          console.log('File created:', file.path);\n          this.onFileCreated(file);\n        } else if (file instanceof TFolder) {\n          console.log('Folder created:', file.path);\n        }\n      })\n    );\n\n    \u002F\u002F File modified\n    this.registerEvent(\n      this.app.vault.on('modify', (file: TAbstractFile) => {\n        if (file instanceof TFile) {\n          console.log('File modified:', file.path);\n          this.onFileModified(file);\n        }\n      })\n    );\n\n    \u002F\u002F File deleted\n    this.registerEvent(\n      this.app.vault.on('delete', (file: TAbstractFile) => {\n        console.log('File deleted:', file.path);\n        this.onFileDeleted(file);\n      })\n    );\n\n    \u002F\u002F File renamed\u002Fmoved\n    this.registerEvent(\n      this.app.vault.on('rename', (file: TAbstractFile, oldPath: string) => {\n        console.log(`File renamed: ${oldPath} -> ${file.path}`);\n        this.onFileRenamed(file, oldPath);\n      })\n    );\n  }\n\n  private onFileCreated(file: TFile) {\n    \u002F\u002F Apply template, add frontmatter, etc.\n  }\n\n  private onFileModified(file: TFile) {\n    \u002F\u002F Update indexes, trigger sync, etc.\n  }\n\n  private onFileDeleted(file: TAbstractFile) {\n    \u002F\u002F Clean up references, update cache, etc.\n  }\n\n  private onFileRenamed(file: TAbstractFile, oldPath: string) {\n    \u002F\u002F Update links, references, etc.\n  }\n}\n```\n\n### Step 3: MetadataCache Events\n```typescript\nimport { Plugin, TFile, CachedMetadata } from 'obsidian';\n\nexport default class MyPlugin extends Plugin {\n  async onload() {\n    \u002F\u002F Metadata changed for a file\n    this.registerEvent(\n      this.app.metadataCache.on('changed', (file: TFile, data: string, cache: CachedMetadata) => {\n        console.log('Metadata changed:', file.path);\n\n        \u002F\u002F Access frontmatter\n        if (cache.frontmatter) {\n          console.log('Frontmatter:', cache.frontmatter);\n        }\n\n        \u002F\u002F Access tags\n        if (cache.tags) {\n          const tags = cache.tags.map(t => t.tag);\n          console.log('Tags:', tags);\n        }\n\n        \u002F\u002F Access links\n        if (cache.links) {\n          const links = cache.links.map(l => l.link);\n          console.log('Links:', links);\n        }\n      })\n    );\n\n    \u002F\u002F All files resolved (vault fully loaded)\n    this.registerEvent(\n      this.app.metadataCache.on('resolved', () => {\n        console.log('All files resolved - vault fully loaded');\n        this.onVaultReady();\n      })\n    );\n  }\n\n  private onVaultReady() {\n    \u002F\u002F Safe to do full vault operations\n    const allFiles = this.app.vault.getMarkdownFiles();\n    console.log(`Vault ready with ${allFiles.length} files`);\n  }\n}\n```\n\n### Step 4: Debounced Event Handling\n```typescript\n\u002F\u002F src\u002Futils\u002Fdebounced-events.ts\nimport { Plugin, TFile } from 'obsidian';\n\nexport class DebouncedEventHandler {\n  private modifyTimeout: Map\u003Cstring, NodeJS.Timeout> = new Map();\n  private debounceMs: number;\n  private handler: (file: TFile) => void;\n\n  constructor(debounceMs: number, handler: (file: TFile) => void) {\n    this.debounceMs = debounceMs;\n    this.handler = handler;\n  }\n\n  handleModify(file: TFile) {\n    \u002F\u002F Clear existing timeout for this file\n    const existing = this.modifyTimeout.get(file.path);\n    if (existing) {\n      clearTimeout(existing);\n    }\n\n    \u002F\u002F Set new debounced timeout\n    const timeout = setTimeout(() => {\n      this.modifyTimeout.delete(file.path);\n      this.handler(file);\n    }, this.debounceMs);\n\n    this.modifyTimeout.set(file.path, timeout);\n  }\n\n  cleanup() {\n    \u002F\u002F Clear all pending timeouts\n    for (const timeout of this.modifyTimeout.values()) {\n      clearTimeout(timeout);\n    }\n    this.modifyTimeout.clear();\n  }\n}\n\n\u002F\u002F Usage in plugin:\nexport default class MyPlugin extends Plugin {\n  private debouncedHandler: DebouncedEventHandler;\n\n  async onload() {\n    this.debouncedHandler = new DebouncedEventHandler(\n      1000, \u002F\u002F 1 second debounce\n      (file) => this.processFileChange(file)\n    );\n\n    this.registerEvent(\n      this.app.vault.on('modify', (file) => {\n        if (file instanceof TFile) {\n          this.debouncedHandler.handleModify(file);\n        }\n      })\n    );\n  }\n\n  onunload() {\n    this.debouncedHandler.cleanup();\n  }\n\n  private processFileChange(file: TFile) {\n    \u002F\u002F Handle the debounced file change\n    console.log('Processing change for:', file.path);\n  }\n}\n```\n\n### Step 5: Custom Event Emitter\n```typescript\n\u002F\u002F src\u002Fevents\u002Fevent-bus.ts\nimport { Events } from 'obsidian';\n\n\u002F\u002F Define custom events\ninterface MyPluginEvents {\n  'index-updated': (count: number) => void;\n  'sync-complete': (success: boolean, error?: string) => void;\n  'settings-changed': (key: string, value: any) => void;\n}\n\nexport class PluginEventBus extends Events {\n  on\u003CK extends keyof MyPluginEvents>(\n    event: K,\n    callback: MyPluginEvents[K],\n    ctx?: any\n  ): EventRef {\n    return super.on(event as string, callback, ctx);\n  }\n\n  off\u003CK extends keyof MyPluginEvents>(\n    event: K,\n    callback: MyPluginEvents[K]\n  ): void {\n    super.off(event as string, callback);\n  }\n\n  trigger\u003CK extends keyof MyPluginEvents>(\n    event: K,\n    ...args: Parameters\u003CMyPluginEvents[K]>\n  ): void {\n    super.trigger(event as string, ...args);\n  }\n}\n\n\u002F\u002F Usage:\nconst eventBus = new PluginEventBus();\n\n\u002F\u002F Subscribe\neventBus.on('index-updated', (count) => {\n  console.log(`Index updated with ${count} items`);\n});\n\n\u002F\u002F Emit\neventBus.trigger('index-updated', 42);\n```\n\n### Step 6: File Watcher Pattern\n```typescript\n\u002F\u002F src\u002Fwatchers\u002Ffile-watcher.ts\nimport { Plugin, TFile } from 'obsidian';\n\ninterface WatchConfig {\n  folder?: string;\n  extension?: string;\n  includePattern?: RegExp;\n  excludePattern?: RegExp;\n}\n\nexport class FileWatcher {\n  private plugin: Plugin;\n  private config: WatchConfig;\n  private callbacks: {\n    onCreate?: (file: TFile) => void;\n    onModify?: (file: TFile) => void;\n    onDelete?: (path: string) => void;\n    onRename?: (file: TFile, oldPath: string) => void;\n  };\n\n  constructor(\n    plugin: Plugin,\n    config: WatchConfig,\n    callbacks: typeof FileWatcher.prototype.callbacks\n  ) {\n    this.plugin = plugin;\n    this.config = config;\n    this.callbacks = callbacks;\n    this.register();\n  }\n\n  private shouldWatch(path: string): boolean {\n    if (this.config.folder && !path.startsWith(this.config.folder)) {\n      return false;\n    }\n    if (this.config.extension && !path.endsWith(this.config.extension)) {\n      return false;\n    }\n    if (this.config.includePattern && !this.config.includePattern.test(path)) {\n      return false;\n    }\n    if (this.config.excludePattern && this.config.excludePattern.test(path)) {\n      return false;\n    }\n    return true;\n  }\n\n  private register() {\n    if (this.callbacks.onCreate) {\n      this.plugin.registerEvent(\n        this.plugin.app.vault.on('create', (file) => {\n          if (file instanceof TFile && this.shouldWatch(file.path)) {\n            this.callbacks.onCreate!(file);\n          }\n        })\n      );\n    }\n\n    if (this.callbacks.onModify) {\n      this.plugin.registerEvent(\n        this.plugin.app.vault.on('modify', (file) => {\n          if (file instanceof TFile && this.shouldWatch(file.path)) {\n            this.callbacks.onModify!(file);\n          }\n        })\n      );\n    }\n\n    if (this.callbacks.onDelete) {\n      this.plugin.registerEvent(\n        this.plugin.app.vault.on('delete', (file) => {\n          if (this.shouldWatch(file.path)) {\n            this.callbacks.onDelete!(file.path);\n          }\n        })\n      );\n    }\n\n    if (this.callbacks.onRename) {\n      this.plugin.registerEvent(\n        this.plugin.app.vault.on('rename', (file, oldPath) => {\n          if (file instanceof TFile && (this.shouldWatch(file.path) || this.shouldWatch(oldPath))) {\n            this.callbacks.onRename!(file, oldPath);\n          }\n        })\n      );\n    }\n  }\n}\n\n\u002F\u002F Usage:\nnew FileWatcher(\n  this,\n  {\n    folder: 'journal\u002F',\n    extension: '.md',\n    excludePattern: \u002Ftemplate\u002Fi,\n  },\n  {\n    onCreate: (file) => console.log('Journal created:', file.path),\n    onModify: (file) => console.log('Journal modified:', file.path),\n  }\n);\n```\n\n## Output\n- Workspace event handlers for UI state\n- Vault event handlers for file operations\n- MetadataCache handlers for content changes\n- Debounced handlers for frequent events\n- Custom event bus for internal communication\n- Filtered file watchers\n\n## Error Handling\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| Memory leak | Unregistered events | Use `registerEvent` |\n| Performance issues | Too many handlers | Debounce frequent events |\n| Missed events | Late registration | Register in `onload` |\n| Stale data | Cache not updated | Use `metadataCache.on('changed')` |\n\n## Examples\n\n### Complete Event-Driven Plugin\n```typescript\nexport default class MyPlugin extends Plugin {\n  async onload() {\n    \u002F\u002F Wait for vault to be ready\n    this.app.workspace.onLayoutReady(() => {\n      this.initializeAfterVaultReady();\n    });\n  }\n\n  private initializeAfterVaultReady() {\n    \u002F\u002F Now safe to access all files\n    this.buildInitialIndex();\n    this.registerAllEvents();\n  }\n\n  private registerAllEvents() {\n    \u002F\u002F File events\n    this.registerEvent(\n      this.app.vault.on('modify', this.handleModify.bind(this))\n    );\n\n    \u002F\u002F Workspace events\n    this.registerEvent(\n      this.app.workspace.on('file-open', this.handleFileOpen.bind(this))\n    );\n  }\n\n  private handleModify(file: TAbstractFile) {\n    if (file instanceof TFile) {\n      \u002F\u002F Update index\n    }\n  }\n\n  private handleFileOpen(file: TFile | null) {\n    if (file) {\n      \u002F\u002F Track recently opened\n    }\n  }\n}\n```\n\n## Resources\n- [Obsidian Events API](https:\u002F\u002Fdocs.obsidian.md\u002FReference\u002FTypeScript+API\u002FEvents)\n- [Workspace Events](https:\u002F\u002Fdocs.obsidian.md\u002FReference\u002FTypeScript+API\u002FWorkspace)\n- [Vault Events](https:\u002F\u002Fdocs.obsidian.md\u002FReference\u002FTypeScript+API\u002FVault)\n\n## Next Steps\nFor performance optimization, see `obsidian-performance-tuning`.\n",{"name":5,"author":48,"license":15,"version":49,"description":50,"allowed-tools":51},"Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Handle Obsidian events and workspace callbacks for plugin development.\nUse when implementing reactive features, handling file changes,\nor responding to user interactions in your plugin.\nTrigger with phrases like \"obsidian events\", \"obsidian callbacks\",\n\"obsidian file change\", \"obsidian workspace events\".\n","Read, Write, Edit","main","90b50ed0778745a80fd5bfb13b1843d45b9e82f7","tests\u002Fext_conformance\u002Fartifacts\u002Fplugins-community\u002Fplugins\u002Fsaas-packs\u002Fobsidian-pack\u002Fskills\u002Fobsidian-webhooks-events",233,"https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust","https:\u002F\u002Fgithub.com\u002FDicklesworthstone","https:\u002F\u002Fwww.jeffreyemanuel.com\u002F","Building in NY","2026-11-15 01:54:15",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add Dicklesworthstone\u002Fpi_agent_rust --skill obsidian-webhooks-events",{"tool":67,"command":68},"bunx","bunx skills add Dicklesworthstone\u002Fpi_agent_rust --skill obsidian-webhooks-events",{"tool":70,"command":71},"pnpm","pnpm dlx skills add Dicklesworthstone\u002Fpi_agent_rust --skill obsidian-webhooks-events","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Fplugins-community\u002Fplugins\u002Fsaas-packs\u002Fobsidian-pack\u002Fskills\u002Fobsidian-webhooks-events\u002FSKILL.md",true,[],[76,109,142,165,190,217],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":80,"licenseFileUrl":81,"sourceHtmlUrl":82,"categories":83,"keywords":89,"publishedAt":108},"01M6FCR7G5A005P364Z6ZWCJDP","theme-factory","Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors\u002Ffonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Ftheme-factory\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Ftheme-factory\u002FSKILL.md",[84],{"categoryNo":85,"categoryName":86,"taxonomyType":87,"taxonomyTypeDesc":88},"01JBSEEDCAT000000000000015","视觉设计","SCENARIO","使用场景",[90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,30,106,107],"theme factory","factory","theme","docs","toolkit","generate","artifacts","SET","fly","slides","landing","html","styling","artifact","pages","themes","you","fonts","2026-11-11 15:11:14",{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":80,"licenseFileUrl":113,"sourceHtmlUrl":114,"categories":115,"keywords":119,"publishedAt":43},"01M6FEGPPK0ZTKCCM0R3E3KS33","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FSKILL.md",[116],{"categoryNo":117,"categoryName":118,"taxonomyType":87,"taxonomyTypeDesc":88},"01JBSEEDCAT000000000000009","前端开发",[120,121,96,122,123,124,125,126,127,128,129,130,131,132,39,133,134,135,33,101,136,137,138,139,27,140,141],"web artifacts builder","web","artifacts builder","builder","frontend","css","components","react","component","routing","state management","state","shadcn","ui","Tools","Tailwind","single-file","simple","ui components","multi","jsx","suite",{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":80,"licenseFileUrl":146,"sourceHtmlUrl":147,"categories":148,"keywords":153,"publishedAt":43},"01M6FEE9VTK1W4GY21AKREJXRG","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FSKILL.md",[149,152],{"categoryNo":150,"categoryName":151,"taxonomyType":87,"taxonomyTypeDesc":88},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":117,"categoryName":118,"taxonomyType":87,"taxonomyTypeDesc":88},[154,155,156,124,157,158,121,159,94,160,133,161,162,163,164,30,27],"testing","webapp testing","webapp","screenshots","playwright","debugging","browser","logs","applications","behavior","local",{"skillNo":166,"name":167,"nameZh":6,"description":168,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":169,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":43},"01M6FE20F7ZTQBFWKF4MPJ2SBX","neuropixels-analysis","Neuropixels neural recording analysis. Load SpikeGLX\u002FOpenEphys data, preprocess, motion correction, Kilosort4 spike sorting, quality metrics, Allen\u002FIBL curation, AI-assisted visual analysis, for Neuropixels 1.0\u002F2.0 extracellular electrophysiology. Use when working with neural recordings, spike sorting, extracellular electrophysiology, or when the user mentions Neuropixels, SpikeGLX, Open Ephys, Kilosort, quality metrics, or unit curation.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fneuropixels-analysis\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fneuropixels-analysis\u002FSKILL.md",[],[173,174,175,176,177,178,179,34,33,180,181,182,183,184,185,186,30,187,188,189,27,24],"analysis","neuropixels analysis","spike","metrics","data","open","quality","recordings","Neural","motion","visual","quality metrics","unit","sorting","curation","recording","load",{"skillNo":191,"name":192,"nameZh":6,"description":193,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":80,"licenseFileUrl":194,"sourceHtmlUrl":195,"categories":196,"keywords":200,"publishedAt":43},"01M6FDP0PDK6F1GGX395C7625Z","skill-creator","Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fskill-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fskill-creator\u002FSKILL.md",[197],{"categoryNo":198,"categoryName":199,"taxonomyType":87,"taxonomyTypeDesc":88},"01JBSEEDCAT000000000000023","Skill与智能体开发",[201,202,203,204,205,206,207,208,209,210,211,212,213,214,30,27,215,24,216],"skill creator","creator","workflows","create","update","capabilities","knowledge","tool","integrations","specialized","guide","new skill","existing skill","users","Existing","new",{"skillNo":218,"name":219,"nameZh":6,"description":220,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":221,"sourceHtmlUrl":222,"categories":223,"keywords":225,"publishedAt":43},"01M6FDM8Y7VK7NYG9SM7QPA3PW","notebooklm","Use this skill to query your Google NotebookLM notebooks directly from Claude Code for source-grounded, citation-backed answers from Gemini. Browser automation, library management, persistent auth. Drastically reduced hallucinations through document-only responses.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002FSKILL.md",[224],{"categoryNo":198,"categoryName":199,"taxonomyType":87,"taxonomyTypeDesc":88},[219,226,227,228,229,230,231,160,232,233,33,234,235,236,237,27,238],"google","browser automation","gemini","automation","auth","code","library","management","only","document","query","Citation","source"]