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

@ -49,7 +49,7 @@ class Cursor 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
###
Section: Managing Cursor Position

View File

@ -105,7 +105,7 @@ class Decoration
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidDestroy: (callback) ->
@emitter.on 'did-destroy', callback
@emitter.once 'did-destroy', callback
###
Section: Decoration Details

View File

@ -129,7 +129,7 @@ class GitRepository
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidDestroy: (callback) ->
@emitter.on 'did-destroy', callback
@emitter.once 'did-destroy', callback
###
Section: Event Subscription

View File

@ -48,7 +48,7 @@ class Gutter
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidDestroy: (callback) ->
@emitter.on 'did-destroy', callback
@emitter.once 'did-destroy', callback
###
Section: Visibility

View File

@ -69,7 +69,7 @@ class PaneAxis extends Model
@emitter.on 'did-replace-child', fn
onDidDestroy: (fn) ->
@emitter.on 'did-destroy', fn
@emitter.once 'did-destroy', fn
onDidChangeFlexScale: (fn) ->
@emitter.on 'did-change-flex-scale', fn

View File

@ -170,7 +170,7 @@ class Pane
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidDestroy: (callback) ->
@emitter.on 'did-destroy', callback
@emitter.once 'did-destroy', callback
# Public: Invoke the given callback when the value of the {::isActive}
# property changes.

View File

@ -40,7 +40,7 @@ module.exports = class PanelContainer {
}
onDidDestroy (callback) {
return this.emitter.on('did-destroy', callback)
return this.emitter.once('did-destroy', callback)
}
/*

View File

@ -66,7 +66,7 @@ class Panel {
//
// Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidDestroy (callback) {
return this.emitter.on('did-destroy', callback)
return this.emitter.once('did-destroy', callback)
}
/*

View File

@ -54,7 +54,7 @@ class Selection 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
###
Section: Managing the selection range

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.