Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. /** This file contains interfaces for Screen Activation Lifecycle hooks that Views can use. */
  2. declare module 'aurelia/lifecycle/view-hooks' {
  3. import {Router, RouterConfiguration, RouteConfig, NavigationInstruction} from "aurelia-router";
  4. /**
  5. * A Navigation Command is any object with a navigate(router: Router) method.
  6. * When a navigation command is encountered, the current navigation will be cancelled and
  7. * control will be passed to the navigation command so it can determine the correct action.
  8. */
  9. export type NavicationCommand = {
  10. navigate(appRouter: Router): void
  11. }
  12.  
  13. /** contains property for each route parameter */
  14. export type RouteParams = Object;
  15.  
  16. export type ActivationResult = boolean | Promise<boolean> | NavicationCommand;
  17.  
  18.  
  19. export interface ConfigureRouter {
  20. /**
  21. * Implement this hook if you want to add sub-routes to your view.
  22. */
  23. configureRouter(config: RouterConfiguration, router: Router);
  24. }
  25.  
  26. export interface CanActivate {
  27. /**
  28. * Implement this hook if you want to control whether or not your view-model can be navigated to.
  29. * Return a boolean value, a promise for a boolean value, or a navigation command.
  30. */
  31. canActivate(params: RouteParams, routerConfig: RouteConfig, navigationInstruction: NavigationInstruction): ActivationResult;
  32. }
  33.  
  34. export interface Activate {
  35. /**
  36. * Implement this hook if you want to perform custom logic just before your view-model is displayed.
  37. * You can optionally return a promise to tell the router to wait to bind and attach the view until after you finish your work.
  38. */
  39. activate(params: RouteParams, routerConfig: RouteConfig, navigationInstruction: NavigationInstruction): void | Promise<any>;
  40. }
  41.  
  42.  
  43. export interface CanDeactivate {
  44. /**
  45. * 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.
  46. * Return a boolean value, a promise for a boolean value, or a navigation command.
  47. */
  48. canDeactivate(): ActivationResult;
  49. }
  50.  
  51. export interface Deactivate {
  52. /**
  53. * Implement this hook if you want to perform custom logic when your view-model is being navigated away from.
  54. * You can optionally return a promise to tell the router to wait until after you finish your work.
  55. */
  56. deactivate(): void | Promise<any>;
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement