From 2c201d3f34095315cdb2ef8b1d2e077271e61547 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Mon, 2 Nov 2015 11:57:31 -0800 Subject: [PATCH] feat(facade): add a way to convert observables into promises --- modules/angular2/src/core/facade/async.dart | 4 ++++ modules/angular2/src/core/facade/async.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/modules/angular2/src/core/facade/async.dart b/modules/angular2/src/core/facade/async.dart index c454330e35..6ffa49ab04 100644 --- a/modules/angular2/src/core/facade/async.dart +++ b/modules/angular2/src/core/facade/async.dart @@ -61,6 +61,10 @@ class ObservableWrapper { static Stream fromPromise(Future f) { return new Stream.fromFuture(f); } + + static Future toPromise(Stream s) { + return s.single; + } } class EventEmitter extends Stream { diff --git a/modules/angular2/src/core/facade/async.ts b/modules/angular2/src/core/facade/async.ts index 33f039dfb3..249f30b19f 100644 --- a/modules/angular2/src/core/facade/async.ts +++ b/modules/angular2/src/core/facade/async.ts @@ -48,6 +48,8 @@ export class ObservableWrapper { static fromPromise(promise: Promise): Observable { return RxObservable.fromPromise(promise); } + + static toPromise(obj: Observable): Promise { return (obj).toPromise(); } } /**