refactor(async): fix ObservableWrapper.isObservable

Makes ObservableWrapper and AsyncPipe work with Observable, Subject, and EventEmitter
This commit is contained in:
Rob Wormald
2015-10-28 21:49:22 -07:00
parent 0378e55fab
commit 389ed2d941
2 changed files with 24 additions and 5 deletions

View File

@ -25,13 +25,12 @@ 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 = null,
onComplete: () => void = null): Object {
static subscribe<T>(emitter: any, onNext: (value: T) => void, onError?: (exception: any) => void,
onComplete?: () => void): Object {
return emitter.subscribe({next: onNext, error: onError, complete: onComplete});
}
static isObservable(obs: any): boolean { return obs instanceof EventEmitter; }
static isObservable(obs: any): boolean { return obs instanceof RxObservable; }
/**
* Returns whether `obs` has any subscribers listening to events.