Last active
July 23, 2016 13:20
-
-
Save atsu85/2777454d6ee215a1b9d3911ce157828d to your computer and use it in GitHub Desktop.
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 interfaces for Screen Activation Lifecycle hooks that Views can use. */ | |
declare module 'aurelia/lifecycle/view-hooks' { | |
import {Router, RouterConfiguration, RouteConfig, NavigationInstruction} from "aurelia-router"; | |
/** | |
* A Navigation Command is any object with a navigate(router: Router) method. | |
* When a navigation command is encountered, the current navigation will be cancelled and | |
* control will be passed to the navigation command so it can determine the correct action. | |
*/ | |
export type NavigationCommand = { | |
navigate(appRouter: Router): void | |
} | |
/** contains property for each route parameter */ | |
export type RouteParams = Object; | |
export type ActivationResult = boolean | Promise<boolean> | NavigationCommand | PromiseLike<boolean>; | |
export interface ConfigureRouter { | |
/** | |
* Implement this hook if you want to add sub-routes to your view. | |
*/ | |
configureRouter(config: RouterConfiguration, router: Router); | |
} | |
export interface CanActivate { | |
/** | |
* Implement this hook if you want to control whether or not your view-model can be navigated to. | |
* Return a boolean value, a promise for a boolean value, or a navigation command. | |
*/ | |
canActivate(params: RouteParams, routerConfig: RouteConfig, navigationInstruction: NavigationInstruction): ActivationResult; | |
} | |
export interface Activate { | |
/** | |
* Implement this hook if you want to perform custom logic just before your view-model is displayed. | |
* You can optionally return a promise to tell the router to wait to bind and attach the view until after you finish your work. | |
*/ | |
activate(params: RouteParams, routerConfig: RouteConfig, navigationInstruction: NavigationInstruction): void | Promise<any>; | |
} | |
export interface CanDeactivate { | |
/** | |
* Implement this hook if you want to control whether or not the router can navigate away from your view-model when moving to a new route. | |
* Return a boolean value, a promise for a boolean value, or a navigation command. | |
*/ | |
canDeactivate(): ActivationResult; | |
} | |
export interface Deactivate { | |
/** | |
* Implement this hook if you want to perform custom logic when your view-model is being navigated away from. | |
* You can optionally return a promise to tell the router to wait until after you finish your work. | |
*/ | |
deactivate(): void | Promise<any>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment