@ -7,14 +7,9 @@
|
||||
*/
|
||||
|
||||
import {NgModuleFactory, ɵisObservable as isObservable, ɵisPromise as isPromise} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {fromPromise} from 'rxjs/observable/fromPromise';
|
||||
import {of } from 'rxjs/observable/of';
|
||||
import {concatAll} from 'rxjs/operator/concatAll';
|
||||
import {every} from 'rxjs/operator/every';
|
||||
import * as l from 'rxjs/operator/last';
|
||||
import {map} from 'rxjs/operator/map';
|
||||
import {mergeAll} from 'rxjs/operator/mergeAll';
|
||||
import {Observable, from, of } from 'rxjs';
|
||||
import {concatAll, every, last as lastValue, map, mergeAll} from 'rxjs/operators';
|
||||
|
||||
import {PRIMARY_OUTLET} from '../shared';
|
||||
|
||||
export function shallowEqualArrays(a: any[], b: any[]): boolean {
|
||||
@ -81,7 +76,7 @@ export function waitForMap<A, B>(
|
||||
const res: {[k: string]: B} = {};
|
||||
|
||||
forEach(obj, (a: A, k: string) => {
|
||||
const mapped = map.call(fn(k, a), (r: B) => res[k] = r);
|
||||
const mapped = fn(k, a).pipe(map((r: B) => res[k] = r));
|
||||
if (k === PRIMARY_OUTLET) {
|
||||
waitHead.push(mapped);
|
||||
} else {
|
||||
@ -89,9 +84,7 @@ export function waitForMap<A, B>(
|
||||
}
|
||||
});
|
||||
|
||||
const concat$ = concatAll.call(of (...waitHead, ...waitTail));
|
||||
const last$ = l.last.call(concat$);
|
||||
return map.call(last$, () => res);
|
||||
return of (...waitHead, ...waitTail).pipe(concatAll(), lastValue(), map(() => res));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,8 +92,7 @@ export function waitForMap<A, B>(
|
||||
* input Observables return `true`.
|
||||
*/
|
||||
export function andObservables(observables: Observable<Observable<any>>): Observable<boolean> {
|
||||
const merged$ = mergeAll.call(observables);
|
||||
return every.call(merged$, (result: any) => result === true);
|
||||
return observables.pipe(mergeAll(), every((result: any) => result === true));
|
||||
}
|
||||
|
||||
export function wrapIntoObservable<T>(value: T | NgModuleFactory<T>| Promise<T>| Observable<T>):
|
||||
@ -113,7 +105,7 @@ export function wrapIntoObservable<T>(value: T | NgModuleFactory<T>| Promise<T>|
|
||||
// Use `Promise.resolve()` to wrap promise-like instances.
|
||||
// Required ie when a Resolver returns a AngularJS `$q` promise to correctly trigger the
|
||||
// change detection.
|
||||
return fromPromise(Promise.resolve(value));
|
||||
return from(Promise.resolve(value));
|
||||
}
|
||||
|
||||
return of (value as T);
|
||||
|
Reference in New Issue
Block a user