Skip to content

Commit

Permalink
Fixed new event registration according to obsidian documentation
Browse files Browse the repository at this point in the history
Obsidian docs says: 
> Any registered event handlers need to be detached whenever the plugin unloads. The safest way to make sure this happens is to use the registerEvent() method.

But it's not used. I changed it.

https://docs.obsidian.md/Plugins/Events
  • Loading branch information
Mideks committed Feb 27, 2024
1 parent 2524f23 commit fb1ed2b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export default class MouseWheelZoomPlugin extends Plugin {

async onload() {
await this.loadSettings();
this.app.workspace.on("window-open", (newWindow: WorkspaceWindow) => this.registerEvents(newWindow.win));
this.registerEvent(
this.app.workspace.on("window-open", (newWindow: WorkspaceWindow) => this.registerEvents(newWindow.win));
);
this.registerEvents(window);

this.addSettingTab(new MouseWheelZoomSettingsTab(this.app, this));
Expand Down

0 comments on commit fb1ed2b

Please sign in to comment.