1 | /** @publicapi @module ng1 */ /** */
|
2 | import { Obj } from '@uirouter/core';
|
3 | /** @hidden */
|
4 | export declare const resolveFactory: () => {
|
5 | /**
|
6 | * Asynchronously injects a resolve block.
|
7 | *
|
8 | * This emulates most of the behavior of the ui-router 0.2.x $resolve.resolve() service API.
|
9 | *
|
10 | * ### Not bundled by default
|
11 | *
|
12 | * This API is no longer not part of the standard `@uirouter/angularjs` bundle.
|
13 | * For users of the prebuilt bundles, add the `release/resolveService.min.js` UMD bundle.
|
14 | * For bundlers (webpack, browserify, etc), add `@uirouter/angularjs/lib/legacy/resolveService`.
|
15 | *
|
16 | * ---
|
17 | *
|
18 | * Given an object `invocables`, where keys are strings and values are injectable functions,
|
19 | * injects each function, and waits for the resulting promise to resolve.
|
20 | * When all resulting promises are resolved, returns the results as an object.
|
21 | *
|
22 | * #### Example:
|
23 | * ```js
|
24 | * let invocables = {
|
25 | * foo: [ '$http', ($http) =>
|
26 | * $http.get('/api/foo').then(resp => resp.data) ],
|
27 | * bar: [ 'foo', '$http', (foo, $http) =>
|
28 | * $http.get('/api/bar/' + foo.barId).then(resp => resp.data) ]
|
29 | * }
|
30 | * $resolve.resolve(invocables)
|
31 | * .then(results => console.log(results.foo, results.bar))
|
32 | * // Logs foo and bar:
|
33 | * // { id: 123, barId: 456, fooData: 'foo data' }
|
34 | * // { id: 456, barData: 'bar data' }
|
35 | * ```
|
36 | *
|
37 | * @param invocables an object which looks like an [[StateDeclaration.resolve]] object; keys are resolve names and values are injectable functions
|
38 | * @param locals key/value pre-resolved data (locals)
|
39 | * @param parent a promise for a "parent resolve"
|
40 | */
|
41 | resolve: (invocables: {
|
42 | [key: string]: Function;
|
43 | }, locals?: {}, parent?: Promise<any>) => Promise<Obj>;
|
44 | };
|