feat(core): upgrade rxjs to 6.0.0-alpha.4 (#22573)

PR Close #22573
This commit is contained in:
Igor Minar
2018-02-27 17:06:06 -05:00
parent c445314239
commit b43f8bc7d3
270 changed files with 10104 additions and 1860 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {HttpRequest} from './request';
import {HttpEvent} from './response';

View File

@ -7,11 +7,8 @@
*/
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {of } from 'rxjs/observable/of';
import {concatMap} from 'rxjs/operator/concatMap';
import {filter} from 'rxjs/operator/filter';
import {map} from 'rxjs/operator/map';
import {Observable, of } from 'rxjs';
import {concatMap, filter, map} from 'rxjs/operators';
import {HttpHandler} from './backend';
import {HttpHeaders} from './headers';
@ -384,7 +381,7 @@ export class HttpClient {
// inside an Observable chain, which causes interceptors to be re-run on every
// subscription (this also makes retries re-run the handler, including interceptors).
const events$: Observable<HttpEvent<any>> =
concatMap.call(of (req), (req: HttpRequest<any>) => this.handler.handle(req));
of (req).pipe(concatMap((req: HttpRequest<any>) => this.handler.handle(req)));
// If coming via the API signature which accepts a previously constructed HttpRequest,
// the only option is to get the event stream. Otherwise, return the event stream if
@ -396,8 +393,8 @@ export class HttpClient {
// The requested stream contains either the full response or the body. In either
// case, the first step is to filter the event stream to extract a stream of
// responses(s).
const res$: Observable<HttpResponse<any>> =
filter.call(events$, (event: HttpEvent<any>) => event instanceof HttpResponse);
const res$: Observable<HttpResponse<any>> = <Observable<HttpResponse<any>>>events$.pipe(
filter((event: HttpEvent<any>) => event instanceof HttpResponse));
// Decide which stream to return.
switch (options.observe || 'body') {
@ -409,33 +406,33 @@ export class HttpClient {
// requested type.
switch (req.responseType) {
case 'arraybuffer':
return map.call(res$, (res: HttpResponse<any>) => {
return res$.pipe(map((res: HttpResponse<any>) => {
// Validate that the body is an ArrayBuffer.
if (res.body !== null && !(res.body instanceof ArrayBuffer)) {
throw new Error('Response is not an ArrayBuffer.');
}
return res.body;
});
}));
case 'blob':
return map.call(res$, (res: HttpResponse<any>) => {
return res$.pipe(map((res: HttpResponse<any>) => {
// Validate that the body is a Blob.
if (res.body !== null && !(res.body instanceof Blob)) {
throw new Error('Response is not a Blob.');
}
return res.body;
});
}));
case 'text':
return map.call(res$, (res: HttpResponse<any>) => {
return res$.pipe(map((res: HttpResponse<any>) => {
// Validate that the body is a string.
if (res.body !== null && typeof res.body !== 'string') {
throw new Error('Response is not a string.');
}
return res.body;
});
}));
case 'json':
default:
// No validation needed for JSON responses, as they can be of any type.
return map.call(res$, (res: HttpResponse<any>) => res.body);
return res$.pipe(map((res: HttpResponse<any>) => res.body));
}
case 'response':
// The response stream was requested directly, so return it.

View File

@ -7,7 +7,7 @@
*/
import {Injectable, InjectionToken} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {HttpHandler} from './backend';
import {HttpRequest} from './request';

View File

@ -7,9 +7,8 @@
*/
import {DOCUMENT} from '@angular/common';
import {Inject, Injectable, InjectionToken} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import {Inject, Injectable} from '@angular/core';
import {Observable, Observer} from 'rxjs';
import {HttpBackend, HttpHandler} from './backend';
import {HttpRequest} from './request';

View File

@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Injectable, Injector, ModuleWithProviders, NgModule, Optional} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Injectable, Injector, ModuleWithProviders, NgModule} from '@angular/core';
import {Observable} from 'rxjs';
import {HttpBackend, HttpHandler} from './backend';
import {HttpClient} from './client';

View File

@ -7,8 +7,7 @@
*/
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import {Observable, Observer} from 'rxjs';
import {HttpBackend} from './backend';
import {HttpHeaders} from './headers';

View File

@ -8,7 +8,7 @@
import {DOCUMENT, ɵparseCookieValue as parseCookieValue} from '@angular/common';
import {Inject, Injectable, InjectionToken, PLATFORM_ID} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {HttpHandler} from './backend';
import {HttpInterceptor} from './interceptor';