Merge pull request #4465 from kwilson/master

Updated Routie defs to include static methods.
This commit is contained in:
Horiuchi_H
2015-05-29 15:40:15 +09:00
2 changed files with 49 additions and 11 deletions
+21 -1
View File
@@ -54,4 +54,24 @@ routie("users/12312312");
routie("*", function () {
});
routie("anything");
routie("anything");
// STATIC
// Lookup
var existing = routie.lookup("users/bob", () => {
});
// Remove
routie.remove("users/bob", () => {
});
// RemoveAll
routie.removeAll();
// Navigate
routie.navigate("users/bob");
routie.navigate("users/bob", { silent: true });
// NoConflict
var myRoutie = routie.noConflict();
+28 -10
View File
@@ -3,15 +3,33 @@
// Definitions by: Adilson <https://github.com/Adilson>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Route {
constructor(path: string, name: string): Route;
addHandler(fn: Function): void;
removeHandler(fn: Function): void;
run(params: any): void;
match(path: string, params: any): boolean;
toURL(params: any): string;
declare module routie {
interface Route {
constructor(path: string, name: string): Route;
addHandler(fn: Function): void;
removeHandler(fn: Function): void;
run(params: any): void;
match(path: string, params: any): boolean;
toURL(params: any): string;
}
interface Routie extends RoutieStatic {
(path: string): void;
(path: string, fn: Function): void;
(routes: { [key: string]: Function }): void;
}
interface RoutieStatic {
lookup(name: string, fn: Function): string;
remove(path: string, fn: Function): void;
removeAll(): void;
navigate(path: string, options?: RouteOptions): void;
noConflict(): Routie;
}
interface RouteOptions {
silent?: boolean;
}
}
declare function routie(path: string): void;
declare function routie(path: string, fn: Function): void;
declare function routie(routes: { [key: string]: Function }): void;
declare var routie: routie.Routie;