Mercurial > obsidian-remember-file-state
comparison src/main.ts @ 12:42396b88c64d
Don't unnecessarily capture the view reference in injected callbacks
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 28 Feb 2022 22:11:17 -0800 |
parents | 6f7f35af6335 |
children | 7da0dec2dc8d |
comparison
equal
deleted
inserted
replaced
11:6f7f35af6335 | 12:42396b88c64d |
---|---|
136 console.debug(`Registering callback on view ${viewId}`, filePath); | 136 console.debug(`Registering callback on view ${viewId}`, filePath); |
137 const _this = this; | 137 const _this = this; |
138 var uninstall = around(view, { | 138 var uninstall = around(view, { |
139 onUnloadFile: function(next) { | 139 onUnloadFile: function(next) { |
140 return async function (unloaded: TFile) { | 140 return async function (unloaded: TFile) { |
141 _this.rememberFileState(unloaded, view); | 141 _this.rememberFileState(unloaded, this); |
142 return await next.call(this, unloaded); | 142 return await next.call(this, unloaded); |
143 }; | 143 }; |
144 } | 144 } |
145 }); | 145 }); |
146 this._viewUninstallers[viewId] = uninstall; | 146 this._viewUninstallers[viewId] = uninstall; |