     @timeout 200, => @destroy()
 
   destroy: ->
+    @emitter.emit 'destroyed'
+    @emitter.dispose()
     @marker.destroy()
     @disposables.dispose()
+
+  onDidDestroy: (f) ->
+    @emitter.on 'destroyed', f
 
   invalidate: ->
     @view.classList.add 'invalid'

    metrics()
    opts.type ?= 'inline'
    {@type} = opts
    @disposables = new CompositeDisposable
    opts.fade ?= not Result.removeLines @editor, start, end
    opts.loading ?= not opts.content

# TODO: better scrolling behaviour
{throttle} = require 'underscore-plus'
{$, $$} = require 'atom-space-pen-views'
{CompositeDisposable, Emitter} = require 'atom'
trees = require '../tree'
views = require '../util/views'
{div, span} = views.tags
