mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge pull request #8053 from oggy/will-destroy-pane
Fire event before a pane is destroyed.
This commit is contained in:
@@ -62,6 +62,9 @@ class PaneContainer extends Model
|
||||
onDidDestroyPane: (fn) ->
|
||||
@emitter.on 'did-destroy-pane', fn
|
||||
|
||||
onWillDestroyPane: (fn) ->
|
||||
@emitter.on 'will-destroy-pane', fn
|
||||
|
||||
onDidChangeActivePane: (fn) ->
|
||||
@emitter.on 'did-change-active-pane', fn
|
||||
|
||||
@@ -178,6 +181,9 @@ class PaneContainer extends Model
|
||||
didAddPane: (event) ->
|
||||
@emitter.emit 'did-add-pane', event
|
||||
|
||||
willDestroyPane: (event) ->
|
||||
@emitter.emit 'will-destroy-pane', event
|
||||
|
||||
didDestroyPane: (event) ->
|
||||
@emitter.emit 'did-destroy-pane', event
|
||||
|
||||
|
||||
@@ -109,6 +109,14 @@ class Pane extends Model
|
||||
onDidActivate: (callback) ->
|
||||
@emitter.on 'did-activate', callback
|
||||
|
||||
# Public: Invoke the given callback before the pane is destroyed.
|
||||
#
|
||||
# * `callback` {Function} to be called before the pane is destroyed.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onWillDestroy: (callback) ->
|
||||
@emitter.on 'will-destroy', callback
|
||||
|
||||
# Public: Invoke the given callback when the pane is destroyed.
|
||||
#
|
||||
# * `callback` {Function} to be called when the pane is destroyed.
|
||||
@@ -573,6 +581,8 @@ class Pane extends Model
|
||||
if @container?.isAlive() and @container.getPanes().length is 1
|
||||
@destroyItems()
|
||||
else
|
||||
@emitter.emit 'will-destroy'
|
||||
@container?.willDestroyPane(pane: this)
|
||||
super
|
||||
|
||||
# Called by model superclass.
|
||||
|
||||
@@ -251,6 +251,16 @@ class Workspace extends Model
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onDidAddPane: (callback) -> @paneContainer.onDidAddPane(callback)
|
||||
|
||||
# Extended: Invoke the given callback before a pane is destroyed in the
|
||||
# workspace.
|
||||
#
|
||||
# * `callback` {Function} to be called before panes are destroyed.
|
||||
# * `event` {Object} with the following keys:
|
||||
# * `pane` The pane to be destroyed.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onWillDestroyPane: (callback) -> @paneContainer.onWillDestroyPane(callback)
|
||||
|
||||
# Extended: Invoke the given callback when a pane is destroyed in the
|
||||
# workspace.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user