Skip to content

Commit

Permalink
fix(navigation): add NavigationResult type
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyGrant committed Oct 23, 2017
1 parent dffe907 commit 089aa37
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
15 changes: 15 additions & 0 deletions src/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,18 @@ interface ActivationStrategy {
*/
replace: 'replace';
}

/**
* The result of a pipeline run.
*/
interface PipelineResult {
status: string;
instruction: NavigationInstruction;
output: any;
completed: boolean;
}

/**
* The result of a router navigation.
*/
type NavigationResult = PipelineResult | boolean;
14 changes: 3 additions & 11 deletions src/pipeline.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PipelineStep } from './interfaces';

/**
* The status of a Pipeline.
*/
Expand Down Expand Up @@ -48,24 +50,14 @@ interface PipelineStep {
run(instruction: NavigationInstruction, next: Next): Promise<any>;
}

/**
* The result of a pipeline run.
*/
interface PipelineResult {
status: string;
instruction: NavigationInstruction;
output: any;
completed: boolean;
}

/**
* The class responsible for managing and processing the navigation pipeline.
*/
export class Pipeline {
/**
* The pipeline steps.
*/
steps: Array<Function|PipelineStep> = [];
steps: Array<Function | PipelineStep> = [];

/**
* Adds a step to the pipeline.
Expand Down
6 changes: 3 additions & 3 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
_normalizeAbsolutePath,
_createRootedPath,
_resolveUrl} from './util';
import {RouteConfig} from './interfaces';
import {RouteConfig, NavigationResult} from './interfaces';

/**
* The primary class responsible for handling routing and navigation.
Expand Down Expand Up @@ -165,7 +165,7 @@ export class Router {
* @param fragment The URL fragment to use as the navigation destination.
* @param options The navigation options.
*/
navigate(fragment: string, options?: any): boolean {
navigate(fragment: string, options?: any): NavigationResult {
if (!this.isConfigured && this.parent) {
return this.parent.navigate(fragment, options);
}
Expand All @@ -182,7 +182,7 @@ export class Router {
* @param params The route parameters to be used when populating the route pattern.
* @param options The navigation options.
*/
navigateToRoute(route: string, params?: any, options?: any): boolean {
navigateToRoute(route: string, params?: any, options?: any): NavigationResult {
let path = this.generate(route, params);
return this.navigate(path, options);
}
Expand Down

0 comments on commit 089aa37

Please sign in to comment.