# Interface TransitionStateHookFn

The signature for State Transition Hooks.

State hooks are registered as onEnter/onRetain/onExit in state declarations. State hooks can additionally be injected with $transitions and $states for the current [[Transition]] and [[StateObject]] in the transition.

Transition State Hooks are callback functions that hook into the lifecycle events of specific states during a transition. As a transition runs, it may exit some states, retain (keep) states, and enter states. As each lifecycle event occurs, the hooks which are registered for the event and that state are called (in priority order).

#### See also:

- [[IHookRegistry.onExit]]
- [[IHookRegistry.onRetain]]
- [[IHookRegistry.onEnter]]

#### Example:

    onEnter: function() { console.log('Entering'); }

Not minification-safe

    onRetain: function($state$) { console.log('Retained ' + $state$.name); }

Annotated for minification-safety

    onExit: [ '$transition$', '$state', function($transition$, $state) {
      // always redirect to 'foo' state when being exited
      if ($transition$.to().name !== 'foo') {
        return $state.target('foo');
      }
    } ]

- TransitionStateHookFn(...injectables: any[]): HookResult

  #### Parameters

  - ...injectables: any[]

  #### Returns HookResult

  an optional [[HookResult]] which may alter the transition

  - Defined in src/router/transition/interface.ts:252