feat(facade): add ObservableWrapper.fromPromise

This commit is contained in:
vsavkin 2015-11-02 09:58:42 -08:00 committed by Victor Savkin
parent d6e7a51d9c
commit 53bd6e1642
2 changed files with 9 additions and 1 deletions

View File

@ -57,6 +57,10 @@ class ObservableWrapper {
static void callComplete(EventEmitter emitter) {
emitter.close();
}
static Stream fromPromise(Future f) {
return new Stream.fromFuture(f);
}
}
class EventEmitter<T> extends Stream<T> {

View File

@ -26,7 +26,7 @@ export class TimerWrapper {
export class ObservableWrapper {
// TODO(vsavkin): when we use rxnext, try inferring the generic type from the first arg
static subscribe<T>(emitter: any, onNext: (value: T) => void, onError?: (exception: any) => void,
onComplete?: () => void): Object {
onComplete: () => void = () => {}): Object {
return emitter.subscribe({next: onNext, error: onError, complete: onComplete});
}
@ -44,6 +44,10 @@ export class ObservableWrapper {
static callError(emitter: EventEmitter<any>, error: any) { emitter.error(error); }
static callComplete(emitter: EventEmitter<any>) { emitter.complete(); }
static fromPromise(promise: Promise<any>): Observable<any> {
return RxObservable.fromPromise(promise);
}
}
/**