   onDidChange: (callback) ->
     return @emitter.on 'did-change', callback
 
+  onDidClassify: (callback) ->
+    return @emitter.on 'did-classify', callback
+
   classifyMessages: (messages)->
     isProject = @linter.state.scope is 'Project'
     activeFile = atom.workspace.getActiveTextEditor()?.getPath()


  destroy: ->
    @messages.clear()
    @emitter.dispose()



Helpers = require('./helpers')
{CompositeDisposable, Emitter} = require 'atom'

###
  Note: We are reclassifying the messages on on Pane Item Change,
  even though we are relinting on that same event, 'cause linters could take time
  and we have to refresh the views immediately
###

class MessageRegistry
  constructor: (@linter)->
    @messages = new Map()
    @emitter = new Emitter
    @subscriptions = new CompositeDisposable
    @subscriptions.add atom.workspace.onDidChangeActivePaneItem =>
      @messages.forEach (messages) => @classifyMessages(messages)
      @emitter.emit 'did-classify'

  set: (linter, messages) ->
    Helpers.validateMessages(messages)
    @classifyMessages(messages)
    @messages.set(linter, messages)
    @emitter.emit 'did-classify'
    @emitter.emit 'did-change', @messages

  delete: (linter) ->
