 
     @disposable = @handleWatcher.onDidChange(@onChange)
 
+  onDidChange: (callback) ->
+    @emitter.on('did-change', callback)
+
   close: ->
+    @emitter.dispose()
     @disposable.dispose()
     @handleWatcher.closeIfNoListener()
 

        when 'rename', 'change', 'delete'
          @path = newFilePath if event is 'rename'
          callback.call(this, event, newFilePath) if typeof callback is 'function'
          @emit('change', event, newFilePath)
        when 'child-rename'
          if @isWatchingParent
            @onChange('rename', newFilePath) if @path is oldFilePath

      binding.unwatch(@handle)
      handleWatchers.remove(@handle)

class PathWatcher
  isWatchingParent: false
  path: null
  handleWatcher: null

  constructor: (filePath, callback) ->
    @path = filePath
    @emitter = new Emitter()

    # On Windows watching a file is emulated by watching its parent folder.
    if process.platform is 'win32'
