mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-24 11:29:30 +08:00
Merge pull request #1374 from mattbrooks2010/master
Added missing tests.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/// <reference path="routie.d.ts" />
|
||||
|
||||
// BASIC
|
||||
|
||||
// There are three ways to call routie. Here is the most basic way:
|
||||
|
||||
routie("users", function () {
|
||||
// This gets called when hash == #users
|
||||
});
|
||||
|
||||
// If you want to define multiple routes you can pass in an object like this:
|
||||
|
||||
routie({
|
||||
"users": function () {
|
||||
},
|
||||
"about": function () {
|
||||
}
|
||||
});
|
||||
|
||||
// If you want to trigger a route manually, you can call routie like this:
|
||||
|
||||
routie("users/bob"); // window.location.hash will be #users/bob
|
||||
|
||||
// ADVANCED
|
||||
|
||||
// Routie also supports regex style routes, so you can do advanced routing like this:
|
||||
|
||||
routie("users/:name", function (name) {
|
||||
// name == "bob";
|
||||
});
|
||||
|
||||
routie("users/bob");
|
||||
|
||||
// Optional params:
|
||||
|
||||
routie("users/?:name", function (name) {
|
||||
//name == undefined
|
||||
//then
|
||||
//name == bob
|
||||
});
|
||||
|
||||
routie("users/");
|
||||
routie("users/bob");
|
||||
|
||||
// Wildcard:
|
||||
|
||||
routie("users/*", function () {
|
||||
});
|
||||
|
||||
routie("users/12312312");
|
||||
|
||||
// Catch all:
|
||||
|
||||
routie("*", function () {
|
||||
});
|
||||
|
||||
routie("anything");
|
||||
Vendored
+1
-1
@@ -4,7 +4,7 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface Route {
|
||||
constructor(path: string, name: string);
|
||||
constructor(path: string, name: string): Route;
|
||||
addHandler(fn: Function): void;
|
||||
removeHandler(fn: Function): void;
|
||||
run(params: any): void;
|
||||
|
||||
Reference in New Issue
Block a user