UNPKG

2.04 kBJavaScriptView Raw
1/**
2 * This indirection is needed to free up Component, etc symbols in the public API
3 * to be used by the decorator versions of these annotations.
4 */
5"use strict";
6var core_private_1 = require('../../core_private');
7var lifecycle_annotations_impl_1 = require('./lifecycle_annotations_impl');
8var lifecycle_annotations_impl_2 = require('./lifecycle_annotations_impl');
9exports.routerCanDeactivate = lifecycle_annotations_impl_2.routerCanDeactivate;
10exports.routerCanReuse = lifecycle_annotations_impl_2.routerCanReuse;
11exports.routerOnActivate = lifecycle_annotations_impl_2.routerOnActivate;
12exports.routerOnDeactivate = lifecycle_annotations_impl_2.routerOnDeactivate;
13exports.routerOnReuse = lifecycle_annotations_impl_2.routerOnReuse;
14/**
15 * Defines route lifecycle hook `CanActivate`, which is called by the router to determine
16 * if a component can be instantiated as part of a navigation.
17 *
18 * <aside class="is-right">
19 * Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface.
20 * This is because the `CanActivate` function is called before the component is instantiated.
21 * </aside>
22 *
23 * The `CanActivate` hook is called with two {@link ComponentInstruction}s as parameters, the first
24 * representing the current route being navigated to, and the second parameter representing the
25 * previous route or `null`.
26 *
27 * ```typescript
28 * @CanActivate((next, prev) => boolean | Promise<boolean>)
29 * ```
30 *
31 * If `CanActivate` returns or resolves to `false`, the navigation is cancelled.
32 * If `CanActivate` throws or rejects, the navigation is also cancelled.
33 * If `CanActivate` returns or resolves to `true`, navigation continues, the component is
34 * instantiated, and the {@link OnActivate} hook of that component is called if implemented.
35 *
36 * ### Example
37 *
38 * {@example router/ts/can_activate/can_activate_example.ts region='canActivate' }
39 */
40exports.CanActivate = core_private_1.makeDecorator(lifecycle_annotations_impl_1.CanActivate);
41//# sourceMappingURL=lifecycle_annotations.js.map
\No newline at end of file