0.0.1 • Published 8 years ago

apress v0.0.1

Weekly downloads
5
License
-
Repository
github
Last release
8 years ago

apress

Apress.js is a simple library for routing on client side in SPA projects.

Example

Simplest usage exmaple of Apress can be found here.

Instalation

$bower install apress --save

Usage

In HTML:

<script src="apress.js"></script>

and then in JS:

apress.addRoute(
  '/hello/world', // route we're looking for, in this example it's http://mysite.com#!/hello/world
  function(){    // listener that fires when the hash matches
    //some action...
  }
);

apress.hashTest(); // this forces the app to fire listener for
                  // the current route, useful for instance on app startup

API

apress.addRoute(route,callback) - adding route, route can be string or regexp. It can also contain one of the two special characters - * for wildcard (so everything will be matched in place of the asterix) or % for 'pass whatever it matches as a callback argument'

apress.hashTest()- manual hash checking

apress.setRoute(route) - setting new route manually

apress.removeRoute(route) - remove previously defined route

apress.getRoute() - get actual route

apress.setErrorPage(function) - set function which is trigger when the route don't match any of the registered patterns

Why apress?

There's no time to explain, just use it! Apres-ski Livigno