UNPKG

2.71 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.registerResolveRemaining = exports.registerLazyResolveState = exports.registerEagerResolvePath = exports.RESOLVE_HOOK_PRIORITY = void 0;
4var common_1 = require("../common/common");
5var resolveContext_1 = require("../resolve/resolveContext");
6var hof_1 = require("../common/hof");
7exports.RESOLVE_HOOK_PRIORITY = 1000;
8/**
9 * A [[TransitionHookFn]] which resolves all EAGER Resolvables in the To Path
10 *
11 * Registered using `transitionService.onStart({}, eagerResolvePath, { priority: 1000 });`
12 *
13 * When a Transition starts, this hook resolves all the EAGER Resolvables, which the transition then waits for.
14 *
15 * See [[StateDeclaration.resolve]]
16 */
17var eagerResolvePath = function (trans) {
18 return new resolveContext_1.ResolveContext(trans.treeChanges().to).resolvePath('EAGER', trans).then(common_1.noop);
19};
20exports.registerEagerResolvePath = function (transitionService) {
21 return transitionService.onStart({}, eagerResolvePath, { priority: exports.RESOLVE_HOOK_PRIORITY });
22};
23/**
24 * A [[TransitionHookFn]] which resolves all LAZY Resolvables for the state (and all its ancestors) in the To Path
25 *
26 * Registered using `transitionService.onEnter({ entering: () => true }, lazyResolveState, { priority: 1000 });`
27 *
28 * When a State is being entered, this hook resolves all the Resolvables for this state, which the transition then waits for.
29 *
30 * See [[StateDeclaration.resolve]]
31 */
32var lazyResolveState = function (trans, state) {
33 return new resolveContext_1.ResolveContext(trans.treeChanges().to).subContext(state.$$state()).resolvePath('LAZY', trans).then(common_1.noop);
34};
35exports.registerLazyResolveState = function (transitionService) {
36 return transitionService.onEnter({ entering: hof_1.val(true) }, lazyResolveState, { priority: exports.RESOLVE_HOOK_PRIORITY });
37};
38/**
39 * A [[TransitionHookFn]] which resolves any dynamically added (LAZY or EAGER) Resolvables.
40 *
41 * Registered using `transitionService.onFinish({}, eagerResolvePath, { priority: 1000 });`
42 *
43 * After all entering states have been entered, this hook resolves any remaining Resolvables.
44 * These are typically dynamic resolves which were added by some Transition Hook using [[Transition.addResolvable]].
45 *
46 * See [[StateDeclaration.resolve]]
47 */
48var resolveRemaining = function (trans) {
49 return new resolveContext_1.ResolveContext(trans.treeChanges().to).resolvePath('LAZY', trans).then(common_1.noop);
50};
51exports.registerResolveRemaining = function (transitionService) {
52 return transitionService.onFinish({}, resolveRemaining, { priority: exports.RESOLVE_HOOK_PRIORITY });
53};
54//# sourceMappingURL=resolve.js.map
\No newline at end of file