feat(facade): add a way to convert observables into promises

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

View File

@ -61,6 +61,10 @@ class ObservableWrapper {
static Stream fromPromise(Future f) { static Stream fromPromise(Future f) {
return new Stream.fromFuture(f); return new Stream.fromFuture(f);
} }
static Future toPromise(Stream s) {
return s.single;
}
} }
class EventEmitter<T> extends Stream<T> { class EventEmitter<T> extends Stream<T> {

View File

@ -48,6 +48,8 @@ export class ObservableWrapper {
static fromPromise(promise: Promise<any>): Observable<any> { static fromPromise(promise: Promise<any>): Observable<any> {
return RxObservable.fromPromise(promise); return RxObservable.fromPromise(promise);
} }
static toPromise(obj: Observable<any>): Promise<any> { return (<any>obj).toPromise(); }
} }
/** /**