add methods types to Navigo and update the version

This commit is contained in:
dominuskernel
2018-01-14 18:35:25 +01:00
parent 07c172e5f6
commit af1e2b71dc
2 changed files with 14 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
// Type definitions for navigo 4.0
// Type definitions for navigo 6.0
// Project: https://github.com/krasimir/navigo
// Definitions by: Adrian Ehrsam <https://github.com/aersamkull>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -20,7 +20,7 @@ interface GenericHooks {
after?(params?: Params): void;
}
type RouteHandler = ((parametersObj: any, query: string) => void) | { as: string; uses(parametersObj: any): void };
type RouteHandler = ((params: Params, query: string) => void) | { as: string; uses(params: Params, query: string): void };
declare class Navigo {
/**
@@ -44,6 +44,8 @@ declare class Navigo {
generate(path: string, params?: any): string;
getLinkPath(link: any): any;
resolve(currentURL?: string): boolean;
link(path: string): string;
@@ -52,9 +54,11 @@ declare class Navigo {
disableIfAPINotAvailable(): void;
historyAPIUpdateMethod(method?: string): void;
hooks(hooks: GenericHooks): void;
pause(): void;
pause(change?: boolean): void;
resume(): void;

View File

@@ -56,7 +56,7 @@ router
.resolve();
router
.on('/user/:id/:action', (params: { id: string; action: string }) => {
.on('/user/:id/:action', (params: Params) => {
// If we have http://site.com/user/42/save as a url then
// params.id = 42
// params.action = save
@@ -64,7 +64,7 @@ router
.resolve();
router
.on('/user/:id/:action', (params: { id: string; action: string }, query: string) => {
.on('/user/:id/:action', (params: Params, query: string) => {
// If we have http://site.com/user/42/save?answer=42 as a url then
// params.id = 42
// params.action = save
@@ -117,6 +117,11 @@ router.pause();
router.navigate('/en/products');
router.resume(); // or .pause(false)
router.pause();
router.historyAPIUpdateMethod('replaceState');
router.disableIfAPINotAvailable();
router.resume();
router.on(
'/user/edit',
() => {