1+ /** @module ng1 */ /** */
12import { State } from "../../state/stateObject" ;
23import { PathNode } from "../../path/node" ;
34import { ResolveContext } from "../../resolve/resolveContext" ;
45import { map } from "../../common/common" ;
56import { resolvablesBuilder } from "../../state/stateBuilder" ;
67
7- export const resolveFactory = ( ) => ( {
8+ /**
9+ * Implementation of the legacy `$resolve` service for angular 1.
10+ */
11+ var $resolve = {
812 /**
13+ * Asynchronously injects a resolve block.
14+ *
915 * This emulates most of the behavior of the ui-router 0.2.x $resolve.resolve() service API.
10- * @param invocables an object, with keys as resolve names and values as injectable functions
16+ *
17+ * Given an object `invocables`, where keys are strings and values are injectable functions,
18+ * injects each function, and waits for the resulting promise to resolve.
19+ * When all resulting promises are resolved, returns the results as an object.
20+ *
21+ * @example
22+ * ```js
23+ *
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 [[StateDefinition.resolve]] object; keys are resolve names and values are injectable functions
1138 * @param locals key/value pre-resolved data (locals)
1239 * @param parent a promise for a "parent resolve"
1340 */
@@ -32,4 +59,7 @@ export const resolveFactory = () => ({
3259
3360 return parent ? parent . then ( resolveData ) : resolveData ( { } ) ;
3461 }
35- } ) ;
62+ } ;
63+
64+ /** @hidden */
65+ export const resolveFactory = ( ) => $resolve ;
0 commit comments