# Class TransitionHook

- Defined in router/transition/transition-hook.js:17
- Defined in router/transition/transition-hook.js:174
- Defined in router/transition/transition-hook.js:180
- Defined in router/transition/transition-hook.js:189
- Defined in router/transition/transition-hook.js:190
- Defined in router/transition/transition-hook.js:191

#####
Index

### Constructors

constructor

### Properties

isSuperseded
options
registeredHook
stateContext
transition
type

### Methods

getNotCurrentRejection
handleHookResult
invokeHook
logError
toString
HANDLE_RESULT
LOG_ERROR
LOG_REJECTED_RESULT
REJECT_ERROR
THROW_ERROR
chain
invokeHooks
runAllHooks

##
Constructors

### constructor

- new TransitionHook(transition, stateContext, registeredHook, options): TransitionHook

- #### Parameters

  - transition: any
  - stateContext: any
  - registeredHook: any
  - options: any

  #### Returns TransitionHook

  - Defined in router/transition/transition-hook.js:71

##
Properties

### isSuperseded

isSuperseded: (() => boolean)

- Defined in router/transition/transition-hook.js:76

### options

options: any

- Defined in router/transition/transition-hook.js:75
- Defined in router/transition/transition-hook.js:79

### registeredHook

registeredHook: any

- Defined in router/transition/transition-hook.js:74

### stateContext

stateContext: any

- Defined in router/transition/transition-hook.js:73

### transition

transition: any

- Defined in router/transition/transition-hook.js:72

### type

type: any

- Defined in router/transition/transition-hook.js:80

##
Methods

### getNotCurrentRejection

- getNotCurrentRejection(): any

- Return a Rejection promise if the transition is no longer current due a new transition has started and superseded this one.

  #### Returns any

  - Defined in router/transition/transition-hook.js:148

### handleHookResult

- handleHookResult(result): any

- This method handles the return value of a Transition Hook.

  A hook can return false (cancel), a TargetState (redirect), or a promise (which may later resolve to false or a redirect)

  This also handles "transition superseded" -- when a new transition was started while the hook was still running

  #### Parameters

  - result: any

  #### Returns any

  - Defined in router/transition/transition-hook.js:123

### invokeHook

- invokeHook(): any

- #### Returns any

  - Defined in router/transition/transition-hook.js:85

### logError

- logError(err): void

- #### Parameters

  - err: any

  #### Returns void

  - Defined in router/transition/transition-hook.js:82

### toString

- toString(): string

- #### Returns string

  - Defined in router/transition/transition-hook.js:159

### `Static` HANDLE_RESULT

- HANDLE_RESULT(hook): ((result: any) => any)

- These GetResultHandler(s) are used by [[invokeHook]] below Each HookType chooses a GetResultHandler (See: [[TransitionService._defineCoreEvents]])

  #### Parameters

  - hook: any

  #### Returns ((result: any) => any)

  - - (result): any

    - #### Parameters

      - result: any

      #### Returns any

  - Defined in router/transition/transition-hook.js:174

### `Static` LOG_ERROR

- LOG_ERROR(hook): ((error: any) => any)

- These GetErrorHandler(s) are used by [[invokeHook]] below Each HookType chooses a GetErrorHandler (See: [[TransitionService._defineCoreEvents]])

  #### Parameters

  - hook: any

  #### Returns ((error: any) => any)

  - - (error): any

    - #### Parameters

      - error: any

      #### Returns any

  - Defined in router/transition/transition-hook.js:189

### `Static` LOG_REJECTED_RESULT

- LOG_REJECTED_RESULT(hook): ((result: any) => any)

- If the result is a promise rejection, log it. Otherwise, ignore the result.

  #### Parameters

  - hook: any

  #### Returns ((result: any) => any)

  - - (result): any

    - #### Parameters

      - result: any

      #### Returns any

  - Defined in router/transition/transition-hook.js:180

### `Static` REJECT_ERROR

- REJECT_ERROR(): ((error: any) => any)

- #### Returns ((error: any) => any)

  - - (error): any

    - #### Parameters

      - error: any

      #### Returns any

  - Defined in router/transition/transition-hook.js:190

### `Static` THROW_ERROR

- THROW_ERROR(): ((error: any) => never)

- #### Returns ((error: any) => never)

  - - (error): never

    - #### Parameters

      - error: any

      #### Returns never

  - Defined in router/transition/transition-hook.js:191

### `Static` chain

- chain(hooks, waitFor): any

- Chains together an array of TransitionHooks.

  Given a list of [[TransitionHook]] objects, chains them together. Each hook is invoked after the previous one completes.

  #### Example:

      var hooks: TransitionHook[] = getHooks();
      let promise: Promise<any> = TransitionHook.chain(hooks);

      promise.then(handleSuccess, handleError);

  #### Parameters

  - hooks: any

    the list of hooks to chain together

  - waitFor: any

    if provided, the chain is `.then()`'ed off this promise

  #### Returns any

  a `Promise` for sequentially invoking the hooks (in order)

  - Defined in router/transition/transition-hook.js:36

### `Static` invokeHooks

- invokeHooks(hooks, doneCallback): any

- Invokes all the provided TransitionHooks, in order. Each hook's return value is checked. If any hook returns a promise, then the rest of the hooks are chained off that promise, and the promise is returned. If no hook returns a promise, then all hooks are processed synchronously.

  #### Parameters

  - hooks: any

    the list of TransitionHooks to invoke

  - doneCallback: any

    a callback that is invoked after all the hooks have successfully completed

  #### Returns any

  a promise for the async result, or the result of the callback

  - Defined in router/transition/transition-hook.js:53

### `Static` runAllHooks

- runAllHooks(hooks): void

- Run all TransitionHooks, ignoring their return value.

  #### Parameters

  - hooks: any

  #### Returns void

  - Defined in router/transition/transition-hook.js:68