Resolvable | @uirouter/core
Options
All
  • Public
  • Public/Protected
  • All
Menu

The basic building block for the resolve system.

Resolvables encapsulate a state's resolve's resolveFn, the resolveFn's declared dependencies, the wrapped (.promise), and the unwrapped-when-complete (.data) result of the resolveFn.

Resolvable.get() either retrieves the Resolvable's existing promise, or else invokes resolve() (which invokes the resolveFn) and returns the resulting promise.

Resolvable.get() and Resolvable.resolve() both execute within a context path, which is passed as the first parameter to those fns.

Hierarchy

  • Resolvable

Implements

Index

Constructors

constructor

  • This constructor creates a Resolvable copy

    Example:

    var resolvable1 = new Resolvable('mytoken', http => http.get('foo.json').toPromise(), [Http]);
    
    var resolvable2 = new Resolvable(UserService, dep => new UserService(dep.data), [SomeDependency]);
    
    var resolvable1Clone = new Resolvable(resolvable1);

    Parameters

    Returns Resolvable

  • This constructor creates a new Resolvable from the plain old ResolvableLiteral javascript object

    Example:

    var resolvable1 = new Resolvable('mytoken', http => http.get('foo.json').toPromise(), [Http]);
    
    var resolvable2 = new Resolvable(UserService, dep => new UserService(dep.data), [SomeDependency]);
    
    var resolvable1Clone = new Resolvable(resolvable1);

    Parameters

    Returns Resolvable

  • This constructor creates a new Resolvable

    Example:

    var resolvable1 = new Resolvable('mytoken', http => http.get('foo.json').toPromise(), [Http]);
    
    var resolvable2 = new Resolvable(UserService, dep => new UserService(dep.data), [SomeDependency]);
    
    var resolvable1Clone = new Resolvable(resolvable1);

    Parameters

    • token: any

      The new resolvable's injection token, such as "userList" (a string) or UserService (a class). When this token is used during injection, the resolved value will be injected.

    • resolveFn: Function

      The function that returns the resolved value, or a promise for the resolved value

    • Optional deps: any[]

      An array of dependencies, which will be injected into the resolveFn

    • Optional policy: ResolvePolicy

      the ResolvePolicy defines when and how the Resolvable is processed

    • Optional data: any

      Pre-resolved data. If the resolve value is already known, it may be provided here.

    Returns Resolvable

Properties

data

data: any

deps

deps: any[]

policy

promise

promise: Promise<any> = undefined

resolveFn

resolveFn: Function

resolved

resolved: boolean = false

token

token: any

Methods

clone

get

getPolicy

resolve

  • Asynchronously resolve this Resolvable's data

    Given a ResolveContext that this Resolvable is found in: Wait for this Resolvable's dependencies, then invoke this Resolvable's function and update the Resolvable's state

    Parameters

    Returns Promise<any>

toString

  • toString(): string

Static fromData

Generated using TypeDoc