feat(facade): add a way to detect if an object is a Promise

This commit is contained in:
vsavkin 2015-11-02 11:57:22 -08:00 committed by Victor Savkin
parent 695923dcd6
commit fc50829481
2 changed files with 6 additions and 0 deletions

View File

@ -34,6 +34,10 @@ class PromiseWrapper {
async.scheduleMicrotask(fn);
}
static bool isPromise(obj) {
return obj is Future;
}
static PromiseCompleter<dynamic> completer() =>
new PromiseCompleter(new Completer());
}

View File

@ -44,6 +44,8 @@ export class PromiseWrapper {
PromiseWrapper.then(PromiseWrapper.resolve(null), computation, (_) => {});
}
static isPromise(obj: any): boolean { return obj instanceof Promise; }
static completer(): PromiseCompleter<any> {
var resolve;
var reject;