mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-19 23:17:16 +03:00
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:
parent
e0c2509bf7
commit
863faffd23
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -40,7 +40,7 @@ module.exports = class PanelContainer {
|
||||
}
|
||||
|
||||
onDidDestroy (callback) {
|
||||
return this.emitter.on('did-destroy', callback)
|
||||
return this.emitter.once('did-destroy', callback)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user