   addItem: (item, index=@getActiveItemIndex() + 1) ->
     return if item in @items
 
+    if typeof item.on is 'function'
+      @subscribe item, 'destroyed', => @removeItem(item, true)
+
     @items.splice(index, 0, item)
     @emit 'item-added', item, index
     @emitter.emit 'did-add-item', {item, index}

{find, compact, extend, last} = require 'underscore-plus'
{Model, Sequence} = require 'theorist'
{Emitter} = require 'event-kit'
Serializable = require 'serializable'
PaneAxis = require './pane-axis'

    super

    @emitter = new Emitter
    @items = []

    @addItems(compact(params?.items ? []))
    @setActiveItem(@items[0]) unless @getActiveItem()?

  # Called by the Serializable mixin during serialization.
  serializeParams: ->
