HookBuilder | UI-Router
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HookBuilder

This class returns applicable TransitionHooks for a specific Transition instance.

Hooks (IEventHook) may be registered globally, e.g., $transitions.onEnter(...), or locally, e.g. myTransition.onEnter(...). The HookBuilder finds matching IEventHooks (where the match criteria is determined by the type of hook)

The HookBuilder also converts IEventHooks objects to TransitionHook objects, which are used to run a Transition.

The HookBuilder constructor is given the $transitions service and a Transition instance. Thus, a HookBuilder instance may only be used for one specific Transition object. (side note: the _treeChanges accessor is private in the Transition class, so we must also provide the Transition's _treeChanges)

Hierarchy

  • HookBuilder

Index

Constructors

Properties

$transitions: TransitionService
baseHookOptions: TransitionHookOptions
fromState: State
toState: State
transition: Transition
transitionOptions: TransitionOptions
treeChanges: TreeChanges

Methods

  • _buildNodeHooks(hookType: string, matchingNodesProp: string, sortHooksFn: function, options?: TransitionHookOptions): TransitionHook[]
  • Returns an array of newly built TransitionHook objects.

  • Returns an array of newly built TransitionHook objects.

    • Finds all IEventHooks registered for the given hookType which matched the transition's TreeChanges.
    • Finds PathNode (or PathNode[]) to use as the TransitionHook context(s)
    • For each of the PathNodes, creates a TransitionHook

    Parameters

    • hookType: string
      :

      the name of the hook registration function, e.g., 'onEnter', 'onFinish'.

    • matchingNodesProp: string
      :

      selects which PathNodes from the IMatchingNodes object to create hooks for.

    • sortHooksFn: function
      :

      a function which compares two HookTuple and returns <1, 0, or >1

    • options Optional: TransitionHookOptions
      :

      any specific Transition Hook Options

    Returns TransitionHook[]


  • _matchingHooks(hookName: string, treeChanges: TreeChanges): IEventHook[]
  • Finds all IEventHooks from:

    • The Transition object instance hook registry
    • The TransitionService ($transitions) global hook registry
  • Finds all IEventHooks from:

    • The Transition object instance hook registry
    • The TransitionService ($transitions) global hook registry

    which matched:

    • the eventType
    • the matchCriteria (to, from, exiting, retained, entering)

    Parameters

    Returns IEventHook[]

    :

    an array of matched [[IEventHook]]s


  • asyncHooks(): Array<any>
  • getOnBeforeHooks(): Array<TransitionHook>
  • getOnEnterHooks(): Array<TransitionHook>
  • getOnErrorHooks(): Array<TransitionHook>
  • getOnExitHooks(): Array<TransitionHook>
  • getOnFinishHooks(): Array<TransitionHook>
  • getOnRetainHooks(): Array<TransitionHook>
  • getOnStartHooks(): Array<TransitionHook>
  • getOnSuccessHooks(): Array<TransitionHook>

Generated using TypeDoc