Davis.js 0.9.9

listener

A module to bind to link clicks and form submits and turn what would normally be http requests into instances of Davis.Request. These request objects are then pushed onto the history stack using the Davis.history module.

This module uses Davis.$, which by defualt is jQuery for its event binding and event object normalization. To use Davis with any, or no, JavaScript framework be sure to provide support for all the methods called on Davis.$.

listen

this.listen()

method

Binds to both link clicks and form submits using jQuery's deleagate.

Will catch all current and future links and forms. Uses the apps settings for the selector to use for links and forms

Source

this.listen = function () {
    Davis.$(document).delegate(this.settings.formSelector, 'submit', submitHandler)
    Davis.$(document).delegate(this.settings.linkSelector, 'click', clickHandler)
  }

unlisten

this.unlisten()

method

Unbinds all click and submit handlers that were attatched with listen.

Will efectivley stop the current app from processing any requests and all links and forms will have their default behaviour restored.

Source

this.unlisten = function () {
    Davis.$(document).undelegate(this.settings.linkSelector, 'click', clickHandler)
    Davis.$(document).undelegate(this.settings.formSelector, 'submit', submitHandler)
  }
}

event

A plugin that adds basic event capabilities to a Davis app, it is included by default.

bind

this.bind()

method

Params

  • event - event name
  • fn - callback

Binds a callback to a named event.

The following events are triggered internally by Davis and can be bound to

  • start : Triggered when the application is started
  • lookupRoute : Triggered before looking up a route. The request being looked up is passed as an argument
  • runRoute : Triggered before running a route. The request and route being run are passed as arguments
  • routeNotFound : Triggered if no route for the current request can be found. The current request is passed as an arugment
  • requestHalted : Triggered when a before filter halts the current request. The current request is passed as an argument
  • unsupported : Triggered when starting a Davis app in a browser that doesn't support html5 pushState

Example

app.bind('runRoute', function () {
  console.log('about to run a route')
})

Source

this.bind = function (event, fn) {
    (callbacks[event] = callbacks[event] || []).push(fn);
    return this;
  };

trigger

this.trigger()

method

Params

  • event - event name
  • ... -

Triggers an event with the given arguments.

Source

this.trigger = function (event) {
    var args = Davis.utils.toArray(arguments, 1),
        handlers = callbacks[event];

    if (!handlers) return this

    for (var i = 0, len = handlers.length; i < len; ++i) {
      handlers[i].apply(this, args)
    }

    return this;
  };
}

logger

A plugin for enhancing the standard logging available through the console object. Automatically included in all Davis apps.

Generates log messages of varying severity in the format

[Sun Jan 23 2011 16:15:21 GMT+0000 (GMT)] <message>

error

error

declaration

Prints an error message to the console if the console is available.

Source

var error = logType('error')

info

info

declaration

Prints an info message to the console if the console is available.

Source

var info = logType('info')

warn

warn

declaration

Prints a warning message to the console if the console is available.

Source

var warn = logType('warn')

Route

Davis.Routes are the main part of a Davis application. They consist of an HTTP method, a path and a callback function. When a link or a form that Davis has bound to are clicked or submitted a request is pushed on the history stack and a route that matches the path and method of the generated request is run.

The path for the route can consist of placeholders for attributes, these will then be available on the request. Simple variables should be prefixed with a colan, and for splat style params use an asterisk.

Inside the callback function 'this' is bound to the request.

Example:

var route = new Davis.Route ('get', '/foo/:id', function (req) {
  var id = req.params['id']
  // do something interesting!
})

var route = new Davis.Route ('get', '/foo/*splat', function (req) {
  var id = req.params['splat']
  // splat will contain everything after the /foo/ in the path.
})

You can include any number of route level 'middleware' when defining routes. These middlewares are run in order and need to explicitly call the next handler in the stack. Using route middleware allows you to share common logic between routes and is also a good place to load any data or do any async calls keeping your main handler simple and focused.

Example:

var loadUser = function (req, next) {
  $.get('/users/current', function (user) {
    req.user = user
    next(req)
  })
}

var route = new Davis.Route ('get', '/foo/:id', loadUser, function (req) {
  renderUser(req.user)
})

match

Route.prototype.match()

method

Params

  • method - the method to match against
  • path - the path to match against

Tests whether or not a route matches a particular request.

Example:

route.match('get', '/foo/12')

Source

Route.prototype.match = function (method, path) {
    this.reset();
    return (this.method.test(method)) && (this.path.test(path))
  }

reset

Route.prototype.reset()

method

Resets the RegExps for method and path

Source

Route.prototype.reset = function () {
    this.method.lastIndex = 0;
    this.path.lastIndex = 0;
  }

run

Route.prototype.run()

method

Runs the callback associated with a particular route against the passed request.

Any named params in the request path are extracted, as per the routes path, and added onto the requests params object.

Example:

route.run(request)

Source

Route.prototype.run = function (request) {
    this.reset();
    var matches = this.path.exec(request.path);
    if (matches) {
      matches.shift();
      for (var i=0; i < matches.length; i++) {
        request.params[this.paramNames[i]] = matches[i];
      };
    };

    var handlers = Davis.utils.map(this.handlers, function (handler, i) {
      return function (req) {
        return handler.call(req, req, handlers[i+1])
      }
    })

    return handlers[0](request)
  }

toString

Route.prototype.toString()

method

Converts the route to a string representation of itself by combining the method and path attributes.

Source

Route.prototype.toString = function () {
    return [this.method, this.path].join(' ');
  }

router

A decorator that adds convinience methods to a Davis.App for easily creating instances of Davis.Route and looking up routes for a particular request.

Provides get, post put and delete method shortcuts for creating instances of Davis.Routes with the corresponding method. This allows simple REST styled routing for a client side JavaScript application.

Example

app.get('/foo/:id', function (req) {
  // get the foo with id = req.params['id']
})

app.post('/foo', function (req) {
  // create a new instance of foo with req.params
})

app.put('/foo/:id', function (req) {
  // update the instance of foo with id = req.params['id']
})

app.del('/foo/:id', function (req) {
  // delete the instance of foo with id = req.params['id']
})

As well as providing convinience methods for creating instances of Davis.Routes the router also provides methods for creating special instances of routes called filters. Before filters run before any matching route is run, and after filters run after any matched route has run. A before filter can return false to halt the running of any matched routes or other before filters.

A filter can take an optional path to match on, or without a path will match every request.

Example

app.before('/foo/:id', function (req) {
  // will only run before request matching '/foo/:id'
})

app.before(function (req) {
  // will run before all routes
})

app.after('/foo/:id', function (req) {
  // will only run after routes matching '/foo/:id'
})

app.after(function (req) {
  // will run after all routes
})

Another special kind of route, called state routes, are also generated using the router. State routes are for requests that will not change the current page location. Instead the page location will remain the same but the current state of the page has changed. This allows for states which the server will not be expected to know about and support.

Example

app.state('/foo/:id', function (req) {
  // will run when the app transitions into the '/foo/:id' state.
})

Using the trans method an app can transition to these kind of states without changing the url location.

For convinience routes can be defined within a common base scope, this is useful for keeping your route definitions simpler and DRYer. A scope can either cover the whole app, or just a subset of the routes.

Example

app.scope('/foo', function () {
  this.get('/:id', function () {
    // will run for routes that match '/foo/:id'
  })
})

route

this.route()

method

Params

  • method - The method for this route.
  • path - The path for this route.
  • handler - The handler for this route, will be called with the request that triggered the route.

Low level method for adding routes to your application.

If called with just a method will return a partially applied function that can create routes with that method. This is used internally to provide shortcuts for get, post, put, delete and state routes.

You normally want to use the higher level methods such as get and post, but this can be useful for extending Davis to work with other kinds of requests.

Example:

app.route('get', '/foo', function (req) {
  // will run when a get request is made to '/foo'
})

app.patch = app.route('patch') // will return a function that can be used to handle requests with method of patch.
app.patch('/bar', function (req) {
  // will run when a patch request is made to '/bar'
})

Source

this.route = function (method, path) {
    var createRoute = function (path) {
      var handlers = Davis.utils.toArray(arguments, 1),
          scope = scopePaths.join(''),
          fullPath, route

      (typeof path == 'string') ? fullPath = scope + path : fullPath = path

      route = new Davis.Route (method, fullPath, handlers)

      routeCollection.push(route)
      return route
    }

    return (arguments.length == 1) ? createRoute : createRoute.apply(this, Davis.utils.toArray(arguments, 1))
  }

get

this.get

property

Params

  • path - The path for this route.
  • handler - The handler for this route, will be called with the request that triggered the route.

A convinience wrapper around app.route for creating get routes.

Source

this.get  = this.route('get')

post

this.post

property

Params

  • path - The path for this route.
  • handler - The handler for this route, will be called with the request that triggered the route.

A convinience wrapper around app.route for creating post routes.

Source

this.post = this.route('post')

put

this.put

property

Params

  • path - The path for this route.
  • handler - The handler for this route, will be called with the request that triggered the route.

A convinience wrapper around app.route for creating put routes.

Source

this.put  = this.route('put')

del

this.del

property

Params

  • path - The path for this route.
  • handler - The handler for this route, will be called with the request that triggered the route.

A convinience wrapper around app.route for creating delete routes.

delete is a reserved word in javascript so use the del method when creating a Davis.Route with a method of delete.

Source

this.del  = this.route('delete')

state

this.state

property

Params

  • path - The path for this route, this will never be seen in the url bar.
  • handler - The handler for this route, will be called with the request that triggered the route

Adds a state route into the apps route collection.

These special kind of routes are not triggered by clicking links or submitting forms, instead they are triggered manually by calling trans.

Routes added using the state method act in the same way as other routes except that they generate a route that is listening for requests that will not change the page location.

Example:

app.state('/foo/:id', function (req) {
  // will run when the app transitions into the '/foo/:id' state.
})

Source

this.state = this.route('state');

scope

this.scope()

method

Params

  • path - The prefix to use as the scope
  • fn - A function that will be executed with the router as its context and the path

Modifies the scope of the router.

If you have many routes that share a common path prefix you can use scope to reduce repeating that path prefix.

You can use scope in two ways, firstly you can set the scope for the whole app by calling scope before defining routes. You can also provide a function to the scope method, and the scope will only apply to those routes defined within this function. It is also possible to nest scopes within other scopes.

Example

// using scope with a function
app.scope('/foo', function () {
  this.get('/bar', function (req) {
    // this route will have a path of '/foo/bar'
  })
})

// setting a global scope for the rest of the application
app.scope('/bar')

// using scope with a function
app.scope('/foo', function () {
  this.scope('/bar', function () {
    this.get('/baz', function (req) {
      // this route will have a path of '/foo/bar/baz'
    })
  })
})

Source

this.scope = function (path, fn) {
    scopePaths.push(path)
    if (arguments.length == 1) return

    fn.call(this, this)
    scopePaths.pop()
  }

trans

this.trans()

method

Params

  • path - The path that represents this state. This will not be seen in the url bar.
  • data - Any additional data that should be sent with the request as params.

Transitions the app into the state identified by the passed path parameter.

This allows the app to enter states without changing the page path through a link click or form submit. If there are handlers registered for this state, added by the state method, they will be triggered.

This method generates a request with a method of 'state', in all other ways this request is identical to those that are generated when clicking links etc.

States transitioned to using this method will not be able to be revisited directly with a page load as there is no url that represents the state.

An optional second parameter can be passed which will be available to any handlers in the requests params object.

Example

app.trans('/foo/1')

app.trans('/foo/1', {
  "bar": "baz"
})

Source

this.trans = function (path, data) {
    if (data) {
      var fullPath = [path, decodeURIComponent(Davis.$.param(data))].join('?')
    } else {
      var fullPath = path
    };

    var req = new Davis.Request({
      method: 'state',
      fullPath: fullPath,
      title: ''
    })

    Davis.location.assign(req)
  }

before

this.before

property

Params

  • path - The optionl path for this filter.
  • handler - The handler for this filter, will be called with the request that triggered the route.

A convinience wrapper around app.filter for creating before filters.

Source

this.before = this.filter('before')

after

this.after

property

Params

  • path - The optionl path for this filter.
  • handler - The handler for this filter, will be called with the request that triggered the route.

A convinience wrapper around app.filter for creating after filters.

Source

this.after = this.filter('after')

lookupBeforeFilter

this.lookupBeforeFilter

property

Params

  • path - The optionl path for this filter.
  • handler - The handler for this filter, will be called with the request that triggered the route.

A convinience wrapper around app.lookupFilter for looking up before filters.

Source

this.lookupBeforeFilter = this.lookupFilter('before')

lookupAfterFilter

this.lookupAfterFilter

property

Params

  • path - The optionl path for this filter.
  • handler - The handler for this filter, will be called with the request that triggered the route.

A convinience wrapper around app.lookupFilter for looking up after filters.

Source

this.lookupAfterFilter  = this.lookupFilter('after')

lookupRoute

this.lookupRoute()

method

Params

  • method - the method to use when looking up a route
  • path - the path to use when looking up a route

Looks for the first route that matches the method and path from a request. Will only find and return the first matched route.

Source

this.lookupRoute = function (method, path) {
    return Davis.utils.filter(routeCollection, function (route) {
      return route.match(method, path)
    })[0];
  };
}

history

A module to normalize and enhance the window.pushState method and window.onpopstate event.

Adds the ability to bind to whenever a new state is pushed onto the history stack and normalizes both of these events into an onChange event.

onChange

onChange()

function

Params

  • handler - a function that will be called on push and pop state.

Bind to the history on change event.

This is not a native event but is fired any time a new state is pushed onto the history stack, the current history is replaced or a state is popped off the history stack. The handler function will be called with a request param which is an instance of Davis.Request.

Source

function onChange(handler) {
    onPushState(handler);
    onPopState(wrapped(handler));
  };

assign

assign

declaration

Params

  • request - the location to be assinged as the current location.

Pushes a request onto the history stack.

This is used internally by Davis to push a new request resulting from either a form submit or a link click onto the history stack, it will also trigger the onpushstate event.

An instance of Davis.Request is expected to be passed, however any object that has a title and a path property will also be accepted.

Source

var assign = changeStateWith('pushState')

replace

replace

declaration

Params

  • request - the location to replace the current location with.

Replace the current state on the history stack.

This is used internally by Davis when performing a redirect. This will trigger an onpushstate event.

An instance of Davis.Request is expected to be passed, however any object that has a title and a path property will also be accepted.

Source

var replace = changeStateWith('replaceState')

current

current()

function

Returns the current location for the application.

Davis.location delegates to this method for getting the apps current location.

Source

function current() {
    return window.location.pathname + (window.location.search ? window.location.search : '')
  }

location

A module that acts as a delegator to any locationDelegate implementation. This abstracts the details of what is being used for the apps routing away from the rest of the library. This allows any kind of routing To be used with Davis as long as it can respond appropriatly to the given delegate methods.

A routing module must respond to the following methods

  • current : Should return the current location for the app
  • assign : Should set the current location of the app based on the location of the passed request.
  • replace : Should at least change the current location to the location of the passed request, for full compatibility it should not add any extra items in the history stack.
  • onChange : Should add calbacks that will be fired whenever the location is changed.

setLocationDelegate

setLocationDelegate()

function

Params

  • the - location delegate to use.

Sets the current location delegate.

The passed delegate will be used for all Davis apps. The delegate must respond to the following four methods current, assign, replace & onChange.

Source

function setLocationDelegate(delegate) {
    locationDelegate = delegate
  }

current

current()

function

Delegates to the locationDelegate.current method.

This should return the current location of the app.

Source

function current() {
    return locationDelegate.current()
  }

assign

assign

declaration

Params

  • req - the request to replace the current location with, either a string or a Davis.Request.
  • opts - the optional options object that will be passed to the location delegate

Delegates to the locationDelegate.assign method.

This should set the current location for the app to that of the passed request object.

Can take either a Davis.Request or a string representing the path of the request to assign.

Source

var assign = sendLocationDelegate('assign')

replace

replace

declaration

Params

  • req - the request to replace the current location with, either a string or a Davis.Request.
  • opts - the optional options object that will be passed to the location delegate

Delegates to the locationDelegate.replace method.

This should replace the current location with that of the passed request. Ideally it should not create a new entry in the browsers history.

Can take either a Davis.Request or a string representing the path of the request to assign.

Source

var replace = sendLocationDelegate('replace')

onChange

onChange()

function

Params

  • handler - callback function to be called on location chnage.

Delegates to the locationDelegate.onChange method.

This should add a callback that will be called any time the location changes. The handler function will be called with a request param which is an instance of Davis.Request.

Source

function onChange(handler) {
    locationDelegate.onChange(handler)
  }

Request

Davis.Requests are created from click and submit events. Davis.Requests are passed to Davis.Routes and are stored in the history stack. They are instantiated by the Davis.listener module.

A request will have a params object which will contain all query params and form params, any named params in a routes path will also be added to the requests params object. Also included is support for rails style nested form params.

By default the request method will be taken from the method attribute for forms or will be defaulted to 'get' for links, however there is support for using a hidden field called _method in your forms to set the correct reqeust method.

Simple get requests can be created by just passing a path when initializing a request, to set the method or title you have to pass in an object.

Each request will have a timestamp property to make it easier to determine if the application is moving forward or backward through the history stack.

Example

var request = new Davis.Request ("/foo/12")

var request = new Davis.Request ("/foo/12", {title: 'foo', method: 'POST'})

var request = new Davis.Request({
  title: "foo",
  fullPath: "/foo/12",
  method: "get"
})

redirect

Request.prototype.redirect()

method

Params

  • path - The path to redirect the current request to
  • opts - The optional options object that will be passed through to the location

Redirects the current request to a new location.

Calling redirect on an instance of Davis.Request will create a new request using the path and title of the current request. Redirected requests always have a method of 'get'.

The request created will replace the current request in the history stack. Redirect is most often useful inside a handler for a form submit. After succesfully handling the form the app can redirect to another path. This means that the current form will not be re-submitted if navigating through the history with the back or forward buttons because the request that the submit generated has been replaced in the history stack.

Example

this.post('/foo', function (req) {
  processFormRequest(req.params)  // do something with the form request
  req.redirect('/bar');
})

Source

Request.prototype.redirect = function (path, opts) {
    Davis.location.replace(new Request ({
      method: 'get',
      fullPath: path,
      title: this.title
    }), opts);
  };

whenStale

Request.prototype.whenStale()

method

Params

  • callback - A single callback that will be called when the request becomes stale.

Adds a callback to be called when the request is stale. A request becomes stale when it is no longer the current request, this normally occurs when a new request is triggered. A request can be marked as stale manually if required. The callback passed to whenStale will be called with the new request that is making the current request stale.

Use the whenStale callback to 'teardown' the objects required for the current route, this gives a chance for views to hide themselves and unbind any event handlers etc.

Example

this.get('/foo', function (req) {
  var fooView = new FooView ()
  fooView.render() // display the foo view
  req.whenStale(function (nextReq) {
    fooView.remove() // stop displaying foo view and unbind any events
  })
})

Source

Request.prototype.whenStale = function (callback) {
    this._staleCallback = callback;
  }

makeStale

Request.prototype.makeStale()

method

Params

  • req - The next request that has been recieved.

Mark the request as stale.

This will cause the whenStale callback to be called.

Source

Request.prototype.makeStale = function (req) {
    this._staleCallback.call(req, req);
  }

location

Request.prototype.location()

method

Returns the location or path that should be pushed onto the history stack.

For get requests this will be the same as the path, for post, put, delete and state requests this will be blank as no location should be pushed onto the history stack.

Source

Request.prototype.location = function () {
    return (this.method === 'get') ? decodeURI(this.fullPath) : ''
  }

toString

Request.prototype.toString()

method

Converts the request to a string representation of itself by combining the method and fullPath attributes.

Source

Request.prototype.toString = function () {
    return [this.method.toUpperCase(), this.path].join(" ")
  };

toJSON

Request.prototype.toJSON()

method

Converts the request to a plain object which can be converted to a JSON string.

Used when pushing a request onto the history stack.

Source

Request.prototype.toJSON = function () {
    return {
      title: this.raw.title,
      fullPath: this.raw.fullPath,
      method: this.raw.method,
      timestamp: this.raw.timestamp
    }
  }

forPageLoad

Request.forPageLoad()

method

Creates a new request for the page on page load.

This is required because usually requests are generated from clicking links or submitting forms however this doesn't happen on a page load but should still be considered a request that the JavaScript app should handle.

Source

Request.forPageLoad = function () {
    return new this ({
      method: 'get',
      // fullPath: window.location.pathname,
      fullPath: Davis.location.current(),
      title: document.title,
      forPageLoad: true
    });
  }

App

Constructor for Davis.App

configure

App.prototype.configure()

method

Params

  • config - This function will be executed with the context bound to the apps setting object, this will also be passed as the first argument to the function.

A convinience function for changing the apps default settings.

Should be used before starting the app to ensure any new settings are picked up and used.

Example:

app.configure(function (config) {
  config.linkSelector = 'a.davis'
  config.formSelector = 'form.davis'
})

Source

App.prototype.configure = function(config) {
    config.call(this.settings, this.settings);
  };

use

App.prototype.use()

method

Params

  • plugin - The plugin to use

Method to include a plugin in this app.

A plugin is just a function that will be evaluated in the context of the app.

Example: app.use(Davis.title)

Source

App.prototype.use = function(plugin) {
    plugin.apply(this, Davis.utils.toArray(arguments, 1))
  };

helpers

App.prototype.helpers()

method

Params

  • helpers - An object containing helpers to mixin to the request

Method to add helper properties to all requests in the application.

Helpers will be added to the Davis.Request.prototype. Care should be taken not to override any existing Davis.Request methods.

Source

App.prototype.helpers = function(helpers) {
    for (property in helpers) {
      if (helpers.hasOwnProperty(property)) Davis.Request.prototype[property] = helpers[property]
    }
  };

settings

App.prototypesettings

property

Settings for the app. These may be overriden directly or by using the configure convinience method.

linkSelector is the jquery selector for all the links on the page that you want Davis to respond to. These links will not trigger a normal http request.

formSelector is similar to link selector but for all the forms that davis will bind to

throwErrors decides whether or not any errors will be caugth by Davis. If this is set to true errors will be thrown so that the request will not be handled by JavaScript, the server will have to provide a response. When set to false errors in a route will be caught and the server will not receive the request.

handleRouteNotFound determines whether or not Davis should handle requests when there is no matching route. If set to false Davis will allow the request to be passed to your server to handle if no matching route can be found.

generateRequestOnPageLoad determines whether a request should be generated for the initial page load. by default this is set to false. A Davis.Request will not be generated with the path of the current page. Setting this to true will cause a request to be passed to your app for the inital page load.

Source

App.prototype.settings = {
    linkSelector: 'a',
    formSelector: 'form',
    throwErrors: true,
    handleRouteNotFound: false,
    generateRequestOnPageLoad: false
  };

start

App.prototype.start()

method

Starts the app's routing.

Apps created using the convinience Davis() function are automatically started.

Starting the app binds all links and forms, so clicks and submits create Davis requests that will be pushed onto the browsers history stack. Browser history change events will be picked up and the request that caused the change will be matched against the apps routes and filters.

Source

App.prototype.start = function(){
    var self = this;

    if (this.running) return

    if (!Davis.supported()) {
      this.trigger('unsupported')
      return
    };

    var runFilterWith = function (request) {
      return function (filter) {
        var result = filter.run(request, request);
        return (typeof result === "undefined" || result);
      }
    }

    var beforeFiltersPass = function (request) {
      return Davis.utils.every(
        self.lookupBeforeFilter(request.method, request.path),
        runFilterWith(request)
      )
    }

    var handleRequest = function (request) {
      if (beforeFiltersPass(request)) {
        self.trigger('lookupRoute', request)
        var route = self.lookupRoute(request.method, request.path);
        if (route) {
          self.trigger('runRoute', request, route);

          try {
            route.run(request)
            self.trigger('routeComplete', request, route)
          } catch (error) {
            self.trigger('routeError', request, route, error)
          }

          Davis.utils.every(
            self.lookupAfterFilter(request.method, request.path),
            runFilterWith(request)
          );

        } else {
          self.trigger('routeNotFound', request);
        }
      } else {
        self.trigger('requestHalted', request)
      }
    }

    var bindToInternalEvents = function () {
      self
        .bind('runRoute', function (request) {
          self.logger.info("runRoute: " + request.toString());
        })
        .bind('routeNotFound', function (request) {
          if (!self.settings.handleRouteNotFound && !request.isForPageLoad) {
            self.stop()
            request.delegateToServer()
          };
          self.logger.warn("routeNotFound: " + request.toString());
        })
        .bind('start', function () {
          self.logger.info("application started")
        })
        .bind('stop', function () {
          self.logger.info("application stopped")
        })
        .bind('routeError', function (request, route, error) {
          if (self.settings.throwErrors) throw(error)
          self.logger.error(error.message, error.stack)
        });

      Davis.location.onChange(function (req) {
        handleRequest(req)
      });

      self.boundToInternalEvents = true
    }

    if (!this.boundToInternalEvents) bindToInternalEvents()

    this.listen();
    this.trigger('start')
    this.running = true;

    if (this.settings.generateRequestOnPageLoad) handleRequest(Davis.Request.forPageLoad())

  };

stop

App.prototype.stop()

method

Stops the app's routing.

Stops the app listening to clicks and submits on all forms and links found using the current apps settings.

Source

App.prototype.stop = function() {
    this.unlisten();
    this.trigger('stop')
    this.running = false
  };

  return App;
})()