     if not _.isFunction(View)
       throw new Error("View '#{key}' not found.")
     View
+
+# Mix in Backbone.Events.
+# TODO: Should this be EventEmitter instead?
+_.extend module.exports.prototype, Backbone.Events

extractParamNamesRe = /:(\w+)/g
firstRender = true

module.exports = class Router extends Backbone.Router

  currentFragment: null
  previousFragment: null

  initialize: (options) ->
    @app = options.app
    @initRoutes()
    @on 'action:start', @trackAction
    @app.on 'reload', @renderView


  # if the initial render is more complicated.
  getMainView: (views) ->
    views[0]

  # Proxy to Backbone.Router.
  navigate: (args...) ->
    @_router.navigate.apply(@_router, args)

  authenticationFilter: (handler, route) ->
    (params, callback) =>
