1 | import { ResolvePolicy, ResolvableLiteral } from './interface';
|
2 | import { ResolveContext } from './resolveContext';
|
3 | import { Transition } from '../transition/transition';
|
4 | import { StateObject } from '../state/stateObject';
|
5 | export declare let defaultResolvePolicy: ResolvePolicy;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export declare class Resolvable implements ResolvableLiteral {
|
19 | token: any;
|
20 | policy: ResolvePolicy;
|
21 | resolveFn: Function;
|
22 | deps: any[];
|
23 | data: any;
|
24 | resolved: boolean;
|
25 | promise: Promise<any>;
|
26 | static fromData: (token: any, data: any) => Resolvable;
|
27 |
|
28 | constructor(resolvable: Resolvable);
|
29 | /** This constructor creates a new Resolvable from the plain old [[ResolvableLiteral]] javascript object */
|
30 | constructor(resolvable: ResolvableLiteral);
|
31 | /**
|
32 | * This constructor creates a new `Resolvable`
|
33 | *
|
34 | * #### Example:
|
35 | * ```js
|
36 | * var resolvable1 = new Resolvable('mytoken', http => http.get('foo.json').toPromise(), [Http]);
|
37 | *
|
38 | * var resolvable2 = new Resolvable(UserService, dep => new UserService(dep.data), [SomeDependency]);
|
39 | *
|
40 | * var resolvable1Clone = new Resolvable(resolvable1);
|
41 | * ```
|
42 | *
|
43 | * @param token The new resolvable's injection token, such as `"userList"` (a string) or `UserService` (a class).
|
44 | * When this token is used during injection, the resolved value will be injected.
|
45 | * @param resolveFn The function that returns the resolved value, or a promise for the resolved value
|
46 | * @param deps An array of dependencies, which will be injected into the `resolveFn`
|
47 | * @param policy the [[ResolvePolicy]] defines when and how the Resolvable is processed
|
48 | * @param data Pre-resolved data. If the resolve value is already known, it may be provided here.
|
49 | */
|
50 | constructor(token: any, resolveFn: Function, deps?: any[], policy?: ResolvePolicy, data?: any);
|
51 | getPolicy(state: StateObject): ResolvePolicy;
|
52 | /**
|
53 | * Asynchronously resolve this Resolvable's data
|
54 | *
|
55 | * Given a ResolveContext that this Resolvable is found in:
|
56 | * Wait for this Resolvable's dependencies, then invoke this Resolvable's function
|
57 | * and update the Resolvable's state
|
58 | */
|
59 | resolve(resolveContext: ResolveContext, trans?: Transition): Promise<any>;
|
60 | /**
|
61 | * Gets a promise for this Resolvable's data.
|
62 | *
|
63 | * Fetches the data and returns a promise.
|
64 | * Returns the existing promise if it has already been fetched once.
|
65 | */
|
66 | get(resolveContext: ResolveContext, trans?: Transition): Promise<any>;
|
67 | toString(): string;
|
68 | clone(): Resolvable;
|
69 | }
|