Merge pull request #2539 from xi/feature-angularjs-when-void

angularjs: allow $q.when to be called w/o args
This commit is contained in:
Basarat Ali Syed
2014-07-24 09:56:25 +10:00
2 changed files with 13 additions and 0 deletions
+7
View File
@@ -95,6 +95,7 @@ module HttpAndRegularPromiseTests {
theAnswer: number;
letters: string[];
snack: string;
nothing?: string;
}
var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => {
@@ -139,6 +140,12 @@ module HttpAndRegularPromiseTests {
dPromise.then((snack: string) => {
$scope.snack = snack;
});
// $q.when may be called without arguments
var ePromise: ng.IPromise<void> = $q.when();
ePromise.then(() => {
$scope.nothing = "really nothing";
});
}
// Test that we can pass around a type-checked success/error Promise Callback
+6
View File
@@ -565,6 +565,12 @@ declare module ng {
* @param value Value or a promise
*/
when<T>(value: T): IPromise<T>;
/**
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
*
* @param value Value or a promise
*/
when(): IPromise<void>;
}
interface IPromise<T> {