# Class StateRegistryProvider

A registry for all of the application's [[StateDeclaration]]s

This API is found at `$stateRegistry` ([[UIRouter.stateRegistry]])

#### Implements

- Defined in src/router/state/state-registry.js:18

##### Index

### Constructors

constructor

### Properties

_root
$get
$injector
builder
listeners
matcher
stateQueue
states
urlService
urlServiceRules
$inject

### Methods

_deregisterTree
decorator
deregister
get
getStateHookBuilder
onStatesChanged
register
root

## Constructors

### constructor

- new StateRegistryProvider(
  urlService: any,
  stateService: any,
  globals: RouterGlobals,
  viewService: any,
  ): StateRegistryProvider

  #### Parameters

  - urlService: any
  - stateService: any
  - globals: RouterGlobals
  - viewService: any

  #### Returns StateRegistryProvider

  - Defined in src/router/state/state-registry.js:32

## Properties

### _root

_root: StateObject

- Defined in src/router/state/state-registry.js:118

### $get

$get: AnnotatedFactory = ...

- Defined in src/router/state/state-registry.js:64

### $injector

$injector: InjectorService

- Defined in src/router/state/state-registry.js:37
- Defined in src/router/state/state-registry.js:72

### builder

builder: StateBuilder

- Defined in src/router/state/state-registry.js:40

### listeners

listeners: any[]

- Defined in src/router/state/state-registry.js:38

### matcher

matcher: StateMatcher

- Defined in src/router/state/state-registry.js:39

### stateQueue

stateQueue: StateQueueManager

- Defined in src/router/state/state-registry.js:48

### states

states: {}

- Defined in src/router/state/state-registry.js:33

### urlService

urlService: any

- Defined in src/router/state/state-registry.js:35

### urlServiceRules

urlServiceRules: any

- Defined in src/router/state/state-registry.js:36

### `Static`$inject

$inject: string[] = ...

- Defined in src/router/state/state-registry.js:19

## Methods

### _deregisterTree

- _deregisterTree(state: any): any[]

  #### Parameters

  - state: any

  #### Returns any[]

  - Defined in src/router/state/state-registry.js:186

### decorator

- decorator(property: any, builderFunction: any): any

  Registers a [[BuilderFunction]] for a specific [[StateObject]] property (e.g., `parent`, `url`, or `path`). More than one BuilderFunction can be registered for a given property.

  The BuilderFunction(s) will be used to define the property on any subsequently built [[StateObject]] objects.

  #### Parameters

  - property: any

    The name of the State property being registered for.

  - builderFunction: any

    The BuilderFunction which will be used to build the State property

  #### Returns any

  a function which deregisters the BuilderFunction

  - Defined in src/router/state/state-registry.js:248

### deregister

- deregister(stateOrName: any): StateObject[]

  Removes a state from the registry

  This removes a state from the registry. If the state has children, they are are also removed from the registry.

  #### Parameters

  - stateOrName: any

    the state's name or object representation

  #### Returns StateObject[]

  a list of removed states

  - Defined in src/router/state/state-registry.js:217

### get

- get(stateOrName: any, base: any, ...args: any): any

  #### Parameters

  - stateOrName: any
  - base: any
  - ...args: any

  #### Returns any

  - Defined in src/router/state/state-registry.js:231

### getStateHookBuilder

- getStateHookBuilder(
  hookName: any,
  ): (stateObject: any) => (trans: any, state: any) => any

  This is a [[StateBuilder.builder]] function for angular1 `onEnter`, `onExit`, `onRetain` callback hooks on a [[StateDeclaration]].

  When the [[StateBuilder]] builds a [[StateObject]] object from a raw [[StateDeclaration]], this builder ensures that those hooks are injectable for @uirouter/angularjs (ng1).

  #### Parameters

  - hookName: any

  #### Returns (stateObject: any) => (trans: any, state: any) => any

  #### Internalapi

  - Defined in src/router/state/state-registry.js:87

### onStatesChanged

- onStatesChanged(listener: any): any

  Listen for a State Registry events

  Adds a callback that is invoked when states are registered or deregistered with the StateRegistry.

  #### Example:

      let allStates = registry.get();

      // Later, invoke deregisterFn() to remove the listener
      let deregisterFn = registry.onStatesChanged((event, states) => {
        switch(event) {
          case: 'registered':
            states.forEach(state => allStates.push(state));
            break;
          case: 'deregistered':
            states.forEach(state => {
              let idx = allStates.indexOf(state);
              if (idx !== -1) allStates.splice(idx, 1);
            });
            break;
        }
      });

  #### Parameters

  - listener: any

    a callback function invoked when the registered states changes. The function receives two parameters, `event` and `state`. See [[StateRegistryListener]]

  #### Returns any

  a function that deregisters the listener

  - Defined in src/router/state/state-registry.js:152

### register

- register(stateDefinition: any): StateObject

  Adds a state to the registry

  Registers a [[StateDeclaration]] or queues it for registration.

  Note: a state will be queued if the state's parent isn't yet registered.

  #### Parameters

  - stateDefinition: any

    the definition of the state to register.

  #### Returns StateObject

  the internal [[StateObject]] object. If the state was successfully registered, then the object is fully built (See: [[StateBuilder]]). If the state was only queued, then the object is not fully built.

  - Defined in src/router/state/state-registry.js:182

### root

- root(): StateObject

  Gets the implicit root state

  Gets the root of the state tree. The root state is implicitly created by ng-router. Note: this returns the internal [[StateObject]] representation, not a [[StateDeclaration]]

  #### Returns StateObject

  the root [[StateObject]]

  - Defined in src/router/state/state-registry.js:167