# Class TransitionHook

- Defined in src/router/transition/transition-hook.js:18
- Defined in src/router/transition/transition-hook.js:180
- Defined in src/router/transition/transition-hook.js:186
- Defined in src/router/transition/transition-hook.js:195
- Defined in src/router/transition/transition-hook.js:196
- Defined in src/router/transition/transition-hook.js:197

##### Index

### Constructors

constructor

### Properties

isSuperseded
options
registeredHook
stateContext
transition
type

### Methods

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

## Constructors

### constructor

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

  #### Parameters

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

  #### Returns TransitionHook

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

## Properties

### isSuperseded

isSuperseded: () => boolean

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

### options

options: any

- Defined in src/router/transition/transition-hook.js:79
- Defined in src/router/transition/transition-hook.js:83

### registeredHook

registeredHook: any

- Defined in src/router/transition/transition-hook.js:78

### stateContext

stateContext: any

- Defined in src/router/transition/transition-hook.js:77

### transition

transition: any

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

### type

type: any

- Defined in src/router/transition/transition-hook.js:84

## 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 src/router/transition/transition-hook.js:154

### handleHookResult

- handleHookResult(result: any): 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 src/router/transition/transition-hook.js:129

### invokeHook

- invokeHook(): any

  #### Returns any

  - Defined in src/router/transition/transition-hook.js:91

### logError

- logError(err: any): void

  #### Parameters

  - err: any

  #### Returns void

  - Defined in src/router/transition/transition-hook.js:87

### toString

- toString(): string

  #### Returns string

  - Defined in src/router/transition/transition-hook.js:165

### `Static` chain

- chain(hooks: any, waitFor: any): 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 src/router/transition/transition-hook.js:37

### `Static` HANDLE_RESULT

- HANDLE_RESULT(hook: any): (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

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

### `Static` invokeHooks

- invokeHooks(hooks: any, doneCallback: any): 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 src/router/transition/transition-hook.js:55

### `Static` LOG_ERROR

- LOG_ERROR(hook: any): (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

  - Defined in src/router/transition/transition-hook.js:195

### `Static` LOG_REJECTED_RESULT

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

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

  #### Parameters

  - hook: any

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

  - Defined in src/router/transition/transition-hook.js:186

### `Static` REJECT_ERROR

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

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

  - Defined in src/router/transition/transition-hook.js:196

### `Static` runAllHooks

- runAllHooks(hooks: any): void

  Run all TransitionHooks, ignoring their return value.

  #### Parameters

  - hooks: any

  #### Returns void

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

### `Static` THROW_ERROR

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

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

  - Defined in src/router/transition/transition-hook.js:197