-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(all): adjust interfaces/impl, add router events export
- Loading branch information
Showing
22 changed files
with
139 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"typescript.tsdk": "aurelia-router/node_modules/typescript/lib" | ||
"typescript.tsdk": "aurelia-router/node_modules/typescript/lib", | ||
"tslint.autoFixOnSave": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { PipelineStatus } from './pipeline-status'; | ||
import { NavigationInstruction } from './navigation-instruction'; | ||
import { Next, StepRunnerFunction } from './interfaces'; | ||
|
||
/**@internal exported for unit testing */ | ||
export function createNextFn(instruction: NavigationInstruction, steps: StepRunnerFunction[]): Next { | ||
let index = -1; | ||
const next: Next = function() { | ||
index++; | ||
|
||
if (index < steps.length) { | ||
let currentStep = steps[index]; | ||
|
||
try { | ||
return currentStep(instruction, next); | ||
} catch (e) { | ||
return next.reject(e); | ||
} | ||
} else { | ||
return next.complete(); | ||
} | ||
} as Next; | ||
|
||
next.complete = createCompletionHandler(next, PipelineStatus.completed); | ||
next.cancel = createCompletionHandler(next, PipelineStatus.canceled); | ||
next.reject = createCompletionHandler(next, PipelineStatus.rejected); | ||
|
||
return next; | ||
} | ||
|
||
|
||
/**@internal exported for unit testing */ | ||
export function createCompletionHandler(next: Next, status: PipelineStatus) { | ||
return (output: any) => Promise | ||
.resolve({ | ||
status, | ||
output, | ||
completed: status === PipelineStatus.completed | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* The status of a Pipeline. | ||
*/ | ||
export enum PipelineStatus { | ||
completed = 'completed', | ||
canceled = 'canceled', | ||
rejected = 'rejected', | ||
running = 'running' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export enum RouterEvent { | ||
processing = 'router:navigation:processing', | ||
error = 'router:navigation:error', | ||
canceled = 'router:navigation:canceled', | ||
complete = 'router:navigation:complete', | ||
success = 'router:navigation:success', | ||
childComplete = 'router:navigation:child:complete' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.