Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit e31175e

Browse files
wesleychogkalpak
authored andcommitted
refactor($q): replace occurrences of .when() with .resolve()
Related to #13709. Closes #15442
1 parent 72f1d54 commit e31175e

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

docs/app/src/examples.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ angular.module('examples', [])
114114

115115
ctrl.prepareExampleData = function() {
116116
if (ctrl.example.manifest) {
117-
return $q.when(ctrl.example);
117+
return $q.resolve(ctrl.example);
118118
}
119119

120120
return getExampleData(ctrl.examplePath).then(function(data) {

docs/content/guide/component-router.ngdoc

+5-5
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ You can see the complete application running below.
215215

216216

217217
function HeroService($q) {
218-
var heroesPromise = $q.when([
218+
var heroesPromise = $q.resolve([
219219
{ id: 11, name: 'Mr. Nice' },
220220
{ id: 12, name: 'Narco' },
221221
{ id: 13, name: 'Bombasto' },
@@ -308,7 +308,7 @@ You can see the complete application running below.
308308

309309

310310
function CrisisService($q) {
311-
var crisesPromise = $q.when([
311+
var crisesPromise = $q.resolve([
312312
{id: 1, name: 'Princess Held Captive'},
313313
{id: 2, name: 'Dragon Burning Cities'},
314314
{id: 3, name: 'Giant Asteroid Heading For Earth'},
@@ -415,7 +415,7 @@ You can see the complete application running below.
415415

416416
function DialogService($q) {
417417
this.confirm = function(message) {
418-
return $q.when(window.confirm(message || 'Is it OK?'));
418+
return $q.resolve(window.confirm(message || 'Is it OK?'));
419419
};
420420
}
421421
</file>
@@ -714,7 +714,7 @@ making an actual server request, perhaps over HTTP.
714714

715715
```js
716716
function HeroService($q) {
717-
var heroesPromise = $q.when([
717+
var heroesPromise = $q.resolve([
718718
{ id: 11, name: 'Mr. Nice' },
719719
...
720720
]);
@@ -991,7 +991,7 @@ have made. The result of the prompt is a promise that can be used in a `$routerC
991991

992992
function DialogService($q) {
993993
this.confirm = function(message) {
994-
return $q.when(window.confirm(message || 'Is it OK?'));
994+
return $q.resolve(window.confirm(message || 'Is it OK?'));
995995
};
996996
}
997997
```

docs/content/guide/forms.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ In the following example we create two directives:
396396

397397
if (ctrl.$isEmpty(modelValue)) {
398398
// consider empty model valid
399-
return $q.when();
399+
return $q.resolve();
400400
}
401401

402402
var def = $q.defer();

src/ng/http.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ function $HttpProvider() {
972972

973973
var requestInterceptors = [];
974974
var responseInterceptors = [];
975-
var promise = $q.when(config);
975+
var promise = $q.resolve(config);
976976

977977
// apply interceptors
978978
forEach(reversedInterceptors, function(interceptor) {

test/ng/httpSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('$http', function() {
5858
return {
5959
requestError: function(error) {
6060
savedConfig.url += error;
61-
return $q.when(savedConfig);
61+
return $q.resolve(savedConfig);
6262
}
6363
};
6464
});
@@ -269,7 +269,7 @@ describe('$http', function() {
269269
$provide.factory('myInterceptor', function($q, $rootScope) {
270270
return {
271271
request: function(config) {
272-
return $q.when('/intercepted').then(function(intercepted) {
272+
return $q.resolve('/intercepted').then(function(intercepted) {
273273
config.url = intercepted;
274274
return config;
275275
});

test/ngAnimate/animationSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ describe('$$animation', function() {
976976
$$animationProvider.drivers[0] = 'dumbDriver';
977977
$provide.factory('dumbDriver', function($q) {
978978
return function stepFn() {
979-
return $q.when(true);
979+
return $q.resolve(true);
980980
};
981981
});
982982
});

0 commit comments

Comments
 (0)