fix(common): introduce isObservable method (#14067)
Closes #8848 PR Close #14067
This commit is contained in:

committed by
Miško Hevery

parent
fe441186e7
commit
ff290af38c
12
modules/@angular/router/src/private_import_core.ts
Normal file
12
modules/@angular/router/src/private_import_core.ts
Normal 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;
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user