Only expect a single 'did-destroy' event

These events will only be fired a single time at most, so we should clean up the listeners after that.

This should help minimize accidental memory leaks.
This commit is contained in:
Matthew Dapena-Tretter
2017-06-27 16:08:16 -07:00
parent e0c2509bf7
commit 863faffd23
10 changed files with 10 additions and 10 deletions

View File

@@ -647,7 +647,7 @@ class TextEditor extends Model
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidDestroy: (callback) ->
@emitter.on 'did-destroy', callback
@emitter.once 'did-destroy', callback
# Extended: Calls your `callback` when a {Cursor} is added to the editor.
# Immediately calls your callback for each existing cursor.