Skip to content

Commit cae6d03

Browse files
BREAKING CHANGE: Move imperative $resolve service out of main bundle
The `$resolve` service's `.resolve()` method can be used to perform async dependency injection imperatively. The code has been moved out of the main angular-ui-router codebase and is now opt-in. For prebuilt bundle users, add `release/resolveService.js` to your project. For self-bundlers (e.g., webpack), add `angular-ui-router/lib/resolveService` as an `import` or `require()`. It's unlikely you use this service. Its most common usage is with the UI-Bootstrap `$modal` service.
1 parent a4b5500 commit cae6d03

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

src/legacy/resolveService.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @module ng1 */ /** */
22
import { State, PathNode, ResolveContext, Obj, mapObj, resolvablesBuilder } from "ui-router-core";
3+
import * as angular from "angular";
34

45
/**
56
* Implementation of the legacy `$resolve` service for angular 1.
@@ -10,6 +11,14 @@ var $resolve = {
1011
*
1112
* This emulates most of the behavior of the ui-router 0.2.x $resolve.resolve() service API.
1213
*
14+
* ### Not bundled by default
15+
*
16+
* This API is no longer not part of the standard `angular-ui-router` bundle.
17+
* For users of the prebuilt bundles, add the `release/resolveService.min.js` UMD bundle.
18+
* For bundlers (webpack, browserify, etc), add `angular-ui-router/lib/legacy/resolveService`.
19+
*
20+
* ---
21+
*
1322
* Given an object `invocables`, where keys are strings and values are injectable functions,
1423
* injects each function, and waits for the resulting promise to resolve.
1524
* When all resulting promises are resolved, returns the results as an object.
@@ -58,3 +67,6 @@ var $resolve = {
5867

5968
/** @hidden */
6069
export const resolveFactory = () => $resolve;
70+
71+
// The old $resolve service
72+
angular.module('ui.router').factory('$resolve', <any> resolveFactory);

src/services.ts

-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
UIRouter, IInjectable, StateParams, TransitionService, StateService, UrlRouterProvider,
2020
UrlRouter, UrlMatcherFactory, ResolveContext, TypedMap
2121
} from "ui-router-core";
22-
import { resolveFactory } from "./legacy/resolveService";
2322
import { ng1ViewsBuilder, ng1ViewConfigFactory } from "./statebuilders/views";
2423
import { TemplateFactory } from "./templateFactory";
2524
import { StateProvider } from "./stateProvider";
@@ -176,9 +175,6 @@ angular.module('ui.router.util').factory('$templateFactory', ['$uiRouter', () =>
176175
// The $view service
177176
angular.module('ui.router').factory('$view', () => router.viewService);
178177

179-
// The old $resolve service
180-
angular.module('ui.router').factory('$resolve', <any> resolveFactory);
181-
182178
// $trace service
183179
angular.module("ui.router").service("$trace", () => trace);
184180
watchDigests.$inject = ['$rootScope'];

test/resolveSpec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import "./util/matchers";
88
import { resolvedValue, resolvedError, caught } from './util/testUtilsNg1';
99
import { ResolveContext, State, PathNode, omit, pick, extend, forEach } from "../src/index";
1010
import { Resolvable, services, StateDeclaration } from "ui-router-core";
11+
import "../src/legacy/resolveService";
1112

1213
let module = angular['mock'].module;
1314
///////////////////////////////////////////////

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"files": [
1515
"src/index.ts",
16-
"src/legacy/stateEvents.ts"
16+
"src/legacy/stateEvents.ts",
17+
"src/legacy/resolveService.ts"
1718
]
1819
}

tsconfig.typedoc.json

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"files": [
1313
"src/index.ts",
1414
"../ui-router-core/src/index.ts",
15+
"src/legacy/stateEvents.ts",
16+
"src/legacy/resolveService.ts",
1517
"node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts"
1618
]
1719
}

0 commit comments

Comments
 (0)