         if handlers = @eventHandlersByEventName?[eventName]
           handlers.forEach (handler) -> handler(args...)
 
+  # Public: Stops executing handlers for a registered event.
+  #
+  # eventName - A {String} name identifying an event
+  # handler - The {Function} to remove from the event. If not provided, all handlers are removed.
   off: (eventName='', handler) ->
     [eventName, namespace] = eventName.split('.')
     eventName = undefined if eventName == ''

_ = require 'underscore'

module.exports =
  on: (eventName, handler) ->
    [eventName, namespace] = eventName.split('.')



    @afterUnsubscribe?() if @subscriptionCount() < subscriptionCountBefore

  # Public: When called, stops triggering any event.
  pauseEvents: ->
    @pauseCount ?= 0
    if @pauseCount++ == 0
      @queuedEvents ?= []

  # Public: When called, resumes triggering events.
  resumeEvents: ->
    if --@pauseCount == 0
      queuedEvents = @queuedEvents
      @queuedEvents = null
      @trigger(event...) for event in queuedEvents

  # Public: Identifies how many events are registered.
  #
  # Returns a `number`.
  subscriptionCount: ->
    count = 0
    for name, handlers of @eventHandlersByEventName
