Add Pane::onWillRemoveItem event.

This commit is contained in:
George Ogata
2015-06-24 00:14:10 -04:00
parent 96a7222b0d
commit 8a5dfeae05
2 changed files with 24 additions and 0 deletions

View File

@@ -163,6 +163,15 @@ class Pane extends Model
onDidRemoveItem: (callback) ->
@emitter.on 'did-remove-item', callback
# Public: Invoke the given callback before an item is removed from the pane.
#
# * `callback` {Function} to be called with when items are removed.
# * `event` {Object} with the following keys:
# * `item` The pane item to be removed.
# * `index` {Number} indicating where the item is located.
onWillRemoveItem: (callback) ->
@emitter.on 'will-remove-item', callback
# Public: Invoke the given callback when an item is moved within the pane.
#
# * `callback` {Function} to be called with when items are moved.
@@ -358,6 +367,8 @@ class Pane extends Model
index = @items.indexOf(item)
return if index is -1
@emitter.emit 'will-remove-item', {item, index, destroyed}
if Grim.includeDeprecatedAPIs and typeof item.on is 'function'
@unsubscribe item
@unsubscribeFromItem(item)