# The state subsystem

This subsystem implements the ui-router state tree

- The StateService has state-related service methods such as:
  - StateService.get: Get a registered StateDeclaration object
  - StateService.go: Transition from the current state to a new state
  - StateService.reload: Reload the current state
  - StateService.target: Get a TargetState (useful when redirecting from a Transition Hook)
  - StateService.onInvalid: Register a callback for when a transition to an invalid state is started
  - StateService.defaultErrorHandler: Register a global callback for when a transition errors
- The StateDeclaration interface defines the shape of a state declaration
- The StateRegistry contains all the registered states
  - States can be added/removed using the StateRegistry.register and StateRegistry.deregister
    - Note: Bootstrap state registration differs by front-end framework.
  - Get notified of state registration/deregistration using StateRegistry.onStatesChanged.

## Index

### Classes

- StateBuilder
- StateMatcher
- StateObject
- StateQueueManager
- StateRegistry
- StateService
- TargetState

### Interfaces

- Builders
- HrefOptions
- LazyLoadResult
- StateDeclaration
- TargetStateDef
- TransitionPromise
- _ViewDeclaration

### Type aliases

- BuilderFunction
- OnInvalidCallback
- RedirectToResult
- ResolveTypes
- StateOrName
- StateRegistryListener
- _StateDeclaration

### Functions

- dataBuilder
- getNavigableBuilder
- getParamsBuilder
- getUrlBuilder
- includesBuilder
- nameBuilder
- parseUrl
- pathBuilder
- resolvablesBuilder
- selfBuilder

## Type aliases

BuilderFunction: function

#### Type declaration

- - (state: StateObject, parent?: BuilderFunction): any

  - #### Parameters

    - ##### state StateObject

    - ##### parent: Optional BuilderFunction

    #### Returns any

- Defined in state/stateBuilder.ts:24

OnInvalidCallback: function

#### Type declaration

- - (toState?: TargetState, fromState?: TargetState, injector?: UIInjector): HookResult

  - #### Parameters

    - ##### toState: Optional TargetState

    - ##### fromState: Optional TargetState

    - ##### injector: Optional UIInjector

    #### Returns HookResult

- Defined in state/stateService.ts:33

RedirectToResult: string | TargetState | object | void

The return value of a [[redirectTo]] function

The return value of a [[redirectTo]] function

- string: a state name
- TargetState: a target state, parameters, and options
- object: an object with a state name and parameters

- Defined in state/interface.ts:89

ResolveTypes: Resolvable | ResolvableLiteral | ProviderLike

- Defined in state/interface.ts:28

StateOrName: string | StateObject | StateDeclaration

- Defined in state/interface.ts:15

StateRegistryListener: function

The signature for the callback function provided to StateRegistry.onStatesChanged.

The signature for the callback function provided to StateRegistry.onStatesChanged.

This callback receives two parameters:

param

  a string; either "registered" or "deregistered"

param

  the list of StateDeclarations that were registered (or deregistered).

#### Type declaration

- - (event: "registered" | "deregistered", states: StateDeclaration[]): void

  - #### Parameters

    - ##### event "registered" | "deregistered"

    - ##### states StateDeclaration[]

    #### Returns void

- Defined in state/stateRegistry.ts:25

_StateDeclaration: StateDeclaration | object

Either a StateDeclaration or an ES6 class that implements StateDeclaration The ES6 class constructor should have no arguments.

Either a StateDeclaration or an ES6 class that implements StateDeclaration The ES6 class constructor should have no arguments.

- Defined in state/interface.ts:751

## Functions

- dataBuilder(state: StateObject): any

- #### Parameters

  - ##### state StateObject

  #### Returns any

  - Defined in state/stateBuilder.ts:51

- getNavigableBuilder(isRoot: function): navigableBuilder

- #### Parameters

  - ##### isRoot function

    - - (state: StateObject): boolean

      - #### Parameters

        - ##### state StateObject

        #### Returns boolean

  #### Returns navigableBuilder

  - Defined in state/stateBuilder.ts:82

- getParamsBuilder(paramFactory: ParamFactory): paramsBuilder

- #### Parameters

  - ##### paramFactory ParamFactory

  #### Returns paramsBuilder

  - Defined in state/stateBuilder.ts:87

- getUrlBuilder($urlMatcherFactoryProvider: UrlMatcherFactory, root: function): urlBuilder

- #### Parameters

  - ##### $urlMatcherFactoryProvider UrlMatcherFactory

  - ##### root function

    - - (): StateObject

      - #### Returns StateObject

  #### Returns urlBuilder

  - Defined in state/stateBuilder.ts:58

- includesBuilder(state: StateObject): object

- #### Parameters

  - ##### state StateObject

  #### Returns object

  - ##### [name: string]: boolean

  - Defined in state/stateBuilder.ts:99

- nameBuilder(state: StateObject): string

- #### Parameters

  - ##### state StateObject

  #### Returns string

  - Defined in state/stateBuilder.ts:42

- parseUrl(url: string): any

- #### Parameters

  - ##### url string

  #### Returns any

  - Defined in state/stateBuilder.ts:18

- pathBuilder(state: StateObject): StateObject[]

- #### Parameters

  - ##### state StateObject

  #### Returns StateObject[]

  - Defined in state/stateBuilder.ts:95

- resolvablesBuilder(state: StateObject): Resolvable[]

- This is a StateBuilder.builder function for the `resolve:` block on a StateDeclaration.

- This is a StateBuilder.builder function for the `resolve:` block on a StateDeclaration.

  When the StateBuilder builds a StateObject object from a raw StateDeclaration, this builder validates the `resolve` property and converts it to a Resolvable array.

  resolve: input value can be:

  { // analyzed but not injected myFooResolve: function() { return "myFooData"; },

  // function.toString() parsed, "DependencyName" dep as string (not min-safe) myBarResolve: function(DependencyName) { return DependencyName.fetchSomethingAsPromise() },

  // Array split; "DependencyName" dep as string myBazResolve: [ "DependencyName", function(dep) { return dep.fetchSomethingAsPromise() },

  // Array split; DependencyType dep as token (compared using ===) myQuxResolve: [ DependencyType, function(dep) { return dep.fetchSometingAsPromise() },

  // val.$inject used as deps // where: // corgeResolve.$inject = ["DependencyName"]; // function corgeResolve(dep) { dep.fetchSometingAsPromise() } // then "DependencyName" dep as string myCorgeResolve: corgeResolve,

  // inject service by name // When a string is found, desugar creating a resolve that injects the named service myGraultResolve: "SomeService" }

  or:

  [ new Resolvable("myFooResolve", function() { return "myFooData" }), new Resolvable("myBarResolve", function(dep) { return dep.fetchSomethingAsPromise() }, [ "DependencyName" ]), { provide: "myBazResolve", useFactory: function(dep) { dep.fetchSomethingAsPromise() }, deps: [ "DependencyName" ] } ]

  #### Parameters

  - ##### state StateObject

  #### Returns Resolvable[]

  - Defined in state/stateBuilder.ts:146

- selfBuilder(state: StateObject): StateDeclaration

- #### Parameters

  - ##### state StateObject

  #### Returns StateDeclaration

  - Defined in state/stateBuilder.ts:46

Generated using TypeDoc