fix(common): introduce isObservable method (#14067)

Closes #8848

PR Close #14067
This commit is contained in:
Dzmitry Shylovich
2017-01-23 20:48:04 +03:00
committed by Miško Hevery
parent fe441186e7
commit ff290af38c
7 changed files with 51 additions and 6 deletions

View File

@ -0,0 +1,12 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {__core_private__ as r} from '@angular/core';
export const isPromise: typeof r.isPromise = r.isPromise;
export const isObservable: typeof r.isObservable = r.isObservable;

View File

@ -16,6 +16,7 @@ import * as l from 'rxjs/operator/last';
import {map} from 'rxjs/operator/map';
import {mergeAll} from 'rxjs/operator/mergeAll';
import {isObservable, isPromise} from '../private_import_core';
import {PRIMARY_OUTLET} from '../shared';
export function shallowEqualArrays(a: any[], b: any[]): boolean {
@ -129,11 +130,11 @@ export function andObservables(observables: Observable<Observable<any>>): Observ
export function wrapIntoObservable<T>(value: T | NgModuleFactory<T>| Promise<T>| Observable<T>):
Observable<T> {
if (value instanceof Observable) {
if (isObservable(value)) {
return value;
}
if (value instanceof Promise) {
if (isPromise(value)) {
return fromPromise(value);
}