UNPKG

2.23 kBTypeScriptView Raw
1import { TreeChanges, TransitionHookPhase } from './interface';
2import { Transition } from './transition';
3import { TransitionHook } from './transitionHook';
4import { TransitionEventType } from './transitionEventType';
5import { RegisteredHook } from './hookRegistry';
6/**
7 * This class returns applicable TransitionHooks for a specific Transition instance.
8 *
9 * Hooks ([[RegisteredHook]]) may be registered globally, e.g., $transitions.onEnter(...), or locally, e.g.
10 * myTransition.onEnter(...). The HookBuilder finds matching RegisteredHooks (where the match criteria is
11 * determined by the type of hook)
12 *
13 * The HookBuilder also converts RegisteredHooks objects to TransitionHook objects, which are used to run a Transition.
14 *
15 * The HookBuilder constructor is given the $transitions service and a Transition instance. Thus, a HookBuilder
16 * instance may only be used for one specific Transition object. (side note: the _treeChanges accessor is private
17 * in the Transition class, so we must also provide the Transition's _treeChanges)
18 */
19export declare class HookBuilder {
20 private transition;
21 constructor(transition: Transition);
22 buildHooksForPhase(phase: TransitionHookPhase): TransitionHook[];
23 /**
24 * Returns an array of newly built TransitionHook objects.
25 *
26 * - Finds all RegisteredHooks registered for the given `hookType` which matched the transition's [[TreeChanges]].
27 * - Finds [[PathNode]] (or `PathNode[]`) to use as the TransitionHook context(s)
28 * - For each of the [[PathNode]]s, creates a TransitionHook
29 *
30 * @param hookType the type of the hook registration function, e.g., 'onEnter', 'onFinish'.
31 */
32 buildHooks(hookType: TransitionEventType): TransitionHook[];
33 /**
34 * Finds all RegisteredHooks from:
35 * - The Transition object instance hook registry
36 * - The TransitionService ($transitions) global hook registry
37 *
38 * which matched:
39 * - the eventType
40 * - the matchCriteria (to, from, exiting, retained, entering)
41 *
42 * @returns an array of matched [[RegisteredHook]]s
43 */
44 getMatchingHooks(hookType: TransitionEventType, treeChanges: TreeChanges, transition: Transition): RegisteredHook[];
45}