Skip to content

Commit fc50829

Browse files
committed
feat(facade): add a way to detect if an object is a Promise
1 parent 695923d commit fc50829

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

modules/angular2/src/core/facade/promise.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class PromiseWrapper {
3434
async.scheduleMicrotask(fn);
3535
}
3636

37+
static bool isPromise(obj) {
38+
return obj is Future;
39+
}
40+
3741
static PromiseCompleter<dynamic> completer() =>
3842
new PromiseCompleter(new Completer());
3943
}

modules/angular2/src/core/facade/promise.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export class PromiseWrapper {
4444
PromiseWrapper.then(PromiseWrapper.resolve(null), computation, (_) => {});
4545
}
4646

47+
static isPromise(obj: any): boolean { return obj instanceof Promise; }
48+
4749
static completer(): PromiseCompleter<any> {
4850
var resolve;
4951
var reject;

0 commit comments

Comments
 (0)