fix(toObservableValue): accommodate all observable inputs #2471
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
from
. This will ensure it works with all types thatrxjs
is compatable with. Also, the checks intoObservableValue
were redundant iffrom
was used. For example, ifx
isObservable
from rxjs, thenfrom(x) === x
would betrue
.from
does all of the necessary checks. Also,from
will do the work of figuring out of it happens to be an observable that has interop with RxJS, or is an observable from another instance of rxjs (in node_modules, Node scenario).x == null
will only returntrue
ifx
isundefined
ornull
.toObservableValue
to be more true to form. If you returnObservable<X> | Observable<Y> | Observable<Z>
, it's really no different thanObservable<X | Y | Z>
, because there's no static/synchronous way to narrow the type of theObservable
to say,Observable<X>
in either scenario.were ill-advised, as they were doing type-narrowing by iterating over an array, making it an O(n) operation just to narrow a type.