 _ = require 'underscore'
 
+# Public: Provides a list of functions that can be used in Atom for event management.
+#
+# Each event can have more than one handler; that is, an event can trigger multiple functions.
 module.exports =
+  # Public: Associates an event name with a function to perform.
+  #
+  # This is called endlessly, until the event is turned {.off}. The {.on} method
+  # calls an `eventName` only once.
+  #
+  # eventName - A {String} name identifying an event
+  # handler - A {Function} that's executed when the event is triggered
   on: (eventName, handler) ->
     [eventName, namespace] = eventName.split('.')
 

        if handlers = @eventHandlersByEventName?[eventName]
          handlers.forEach (handler) -> handler(args...)

  off: (eventName='', handler) ->
    [eventName, namespace] = eventName.split('.')
    eventName = undefined if eventName == ''

    @afterSubscribe?()


  # Public: Associates an event name with a function to perform only once.
  #
  # eventName - A {String} name identifying an event
  # handler - A {Function} that's executed when the event is triggered
  one: (eventName, handler) ->
    oneShotHandler = (args...) =>
      @off(eventName, oneShotHandler)
