Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
a tiny, fluent JavaScript response router
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
externals
tests
.gitignore
.gitmodules
MIT-License.txt
README.md
frontal.jquery.js
frontal.jquery.min.js
frontal.js
frontal.min.js

README.md

API Reference

$frn

$frn( path, fn ) .add( path, fn )
Add a rule to the chain. fn will be executed if the path string partially or completely matches the remaining location.

$frn( RegExp, fn ) .add( RegExp, fn )
Add a rule to the chain. fn will be executed if the RegExp partially or completely matches the remaining location.

$frn( RuleArray ) .add( RuleArray )
Add several rules to the chain.

.location( path )
Set the path to use for rule matching.

.location( )
Get the remaining unmatched path.

.data( key, value )
Store arbitrary data identified by a key string.

.data( key )
Retrieve previously stored data identified by a key string.

.data( )
Retrieve all previously stored data as an object, key: value.

.queue([String])
Start queueing rules for execution later. Pass an optional string identifier to create a custom queue.

.done( )
Stop queueing.

.clear([String])
Clear all rules from the queue. Pass a string to clear a custom queue.

.dispatch([String])
Dispatch the queue. Pass a string to dispatch a custom queue.

RuleArray
A nested array literal

[
  ['path', function(){}],
  [/path/, function(){}]
];

Example usage:

$frn('/videos', function(){
    this.add('/view /edit', function(data){
        alert(data.title);
    });
})

$frn.queue('Special')
  .add('/', function(){
    alert('See this when dispatching a custom queue'); 
  })
  .done();
Something went wrong with that request. Please try again.