From 7bcfc0db09aa6db485dca1a1c3d67b0580f25f0d Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Fri, 13 Nov 2020 08:05:17 +0000 Subject: [PATCH] refactor(core): remove isObservable TODO (#39669) This commit removes the TODO comment that proposed that we use the built-in RxJS `isObservable()` function. This is not a viable approach since the built-in function requires that the `obj` contains additional methods that our "observable" types (such as `EventEmitter`) do not necessarily have. See #39643 for more information. PR Close #39669 --- packages/core/src/util/lang.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/util/lang.ts b/packages/core/src/util/lang.ts index 77a2355767..1cd63a1b0c 100644 --- a/packages/core/src/util/lang.ts +++ b/packages/core/src/util/lang.ts @@ -19,9 +19,13 @@ export function isPromise(obj: any): obj is Promise { /** * Determine if the argument is an Observable + * + * Strictly this tests that the `obj` is `Subscribable`, since `Observable` + * types need additional methods, such as `lift()`. But it is adequate for our + * needs since within the Angular framework code we only ever need to use the + * `subscribe()` method, and RxJS has mechanisms to wrap `Subscribable` objects + * into `Observable` as needed. */ export function isObservable(obj: any|Observable): obj is Observable { - // TODO: use isObservable once we update pass rxjs 6.1 - // https://github.com/ReactiveX/rxjs/blob/master/CHANGELOG.md#610-2018-05-03 return !!obj && typeof obj.subscribe === 'function'; }