@ -10,15 +10,8 @@ const globals = {
|
||||
'@angular/core': 'ng.core',
|
||||
'@angular/platform-browser': 'ng.platformBrowser',
|
||||
'@angular/common': 'ng.common',
|
||||
'rxjs/Observable': 'Rx',
|
||||
'rxjs/Observer': 'Rx',
|
||||
'rxjs/Subject': 'Rx',
|
||||
|
||||
'rxjs/observable/of': 'Rx.Observable',
|
||||
|
||||
'rxjs/operator/concatMap': 'Rx.Observable.prototype',
|
||||
'rxjs/operator/filter': 'Rx.Observable.prototype',
|
||||
'rxjs/operator/map': 'Rx.Observable.prototype',
|
||||
'rxjs': 'rxjs',
|
||||
'rxjs/operators': 'rxjs.operators',
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -6,10 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import 'rxjs/add/operator/toArray';
|
||||
import 'rxjs/add/operator/toPromise';
|
||||
|
||||
import {ddescribe, describe, iit, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {toArray} from 'rxjs/operators';
|
||||
|
||||
import {HttpClient} from '../src/client';
|
||||
import {HttpErrorResponse, HttpEventType, HttpResponse} from '../src/response';
|
||||
@ -77,7 +75,7 @@ import {HttpClientTestingBackend} from '../testing/src/backend';
|
||||
backend.expectOne('/test').flush(body);
|
||||
});
|
||||
it('that returns a stream of events', (done: DoneFn) => {
|
||||
client.get('/test', {observe: 'events'}).toArray().toPromise().then(events => {
|
||||
client.get('/test', {observe: 'events'}).pipe(toArray()).toPromise().then(events => {
|
||||
expect(events.length).toBe(2);
|
||||
let x = HttpResponse;
|
||||
expect(events[0].type).toBe(HttpEventType.Sent);
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import {ddescribe, describe, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {toArray} from 'rxjs/operators';
|
||||
|
||||
import {JSONP_ERR_NO_CALLBACK, JSONP_ERR_WRONG_METHOD, JSONP_ERR_WRONG_RESPONSE_TYPE, JsonpClientBackend} from '../src/jsonp';
|
||||
import {HttpRequest} from '../src/request';
|
||||
@ -35,7 +36,7 @@ const SAMPLE_REQ = new HttpRequest<never>('JSONP', '/test');
|
||||
backend = new JsonpClientBackend(home, document);
|
||||
});
|
||||
it('handles a basic request', (done: DoneFn) => {
|
||||
backend.handle(SAMPLE_REQ).toArray().subscribe(events => {
|
||||
backend.handle(SAMPLE_REQ).pipe(toArray()).subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.Response,
|
||||
@ -47,7 +48,7 @@ const SAMPLE_REQ = new HttpRequest<never>('JSONP', '/test');
|
||||
});
|
||||
it('handles an error response properly', (done: DoneFn) => {
|
||||
const error = new Error('This is a test error');
|
||||
backend.handle(SAMPLE_REQ).toArray().subscribe(undefined, (err: HttpErrorResponse) => {
|
||||
backend.handle(SAMPLE_REQ).pipe(toArray()).subscribe(undefined, (err: HttpErrorResponse) => {
|
||||
expect(err.status).toBe(0);
|
||||
expect(err.error).toBe(error);
|
||||
done();
|
||||
|
@ -6,11 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import {Injectable, Injector} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
|
||||
import {HttpHandler} from '../src/backend';
|
||||
import {HttpClient} from '../src/client';
|
||||
@ -28,14 +27,14 @@ class TestInterceptor implements HttpInterceptor {
|
||||
const existing = req.headers.get('Intercepted');
|
||||
const next = !!existing ? existing + ',' + this.value : this.value;
|
||||
req = req.clone({setHeaders: {'Intercepted': next}});
|
||||
return delegate.handle(req).map(event => {
|
||||
return delegate.handle(req).pipe(map(event => {
|
||||
if (event instanceof HttpResponse) {
|
||||
const existing = event.headers.get('Intercepted');
|
||||
const next = !!existing ? existing + ',' + this.value : this.value;
|
||||
return event.clone({headers: event.headers.set('Intercepted', next)});
|
||||
}
|
||||
return event;
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,8 @@
|
||||
*/
|
||||
|
||||
import {ddescribe, describe, iit, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs';
|
||||
import {toArray} from 'rxjs/operators';
|
||||
|
||||
import {HttpRequest} from '../src/request';
|
||||
import {HttpDownloadProgressEvent, HttpErrorResponse, HttpEvent, HttpEventType, HttpHeaderResponse, HttpResponse, HttpResponseBase, HttpUploadProgressEvent} from '../src/response';
|
||||
@ -148,27 +149,29 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||
});
|
||||
describe('progress events', () => {
|
||||
it('are emitted for download progress', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST.clone({reportProgress: true})).toArray().subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.ResponseHeader,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
const [progress1, progress2, response] = [
|
||||
events[2] as HttpDownloadProgressEvent, events[3] as HttpDownloadProgressEvent,
|
||||
events[4] as HttpResponse<string>
|
||||
];
|
||||
expect(progress1.partialText).toBe('down');
|
||||
expect(progress1.loaded).toBe(100);
|
||||
expect(progress1.total).toBe(300);
|
||||
expect(progress2.partialText).toBe('download');
|
||||
expect(progress2.loaded).toBe(200);
|
||||
expect(progress2.total).toBe(300);
|
||||
expect(response.body).toBe('downloaded');
|
||||
done();
|
||||
});
|
||||
backend.handle(TEST_POST.clone({reportProgress: true}))
|
||||
.pipe(toArray())
|
||||
.subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.ResponseHeader,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
const [progress1, progress2, response] = [
|
||||
events[2] as HttpDownloadProgressEvent, events[3] as HttpDownloadProgressEvent,
|
||||
events[4] as HttpResponse<string>
|
||||
];
|
||||
expect(progress1.partialText).toBe('down');
|
||||
expect(progress1.loaded).toBe(100);
|
||||
expect(progress1.total).toBe(300);
|
||||
expect(progress2.partialText).toBe('download');
|
||||
expect(progress2.loaded).toBe(200);
|
||||
expect(progress2.total).toBe(300);
|
||||
expect(response.body).toBe('downloaded');
|
||||
done();
|
||||
});
|
||||
factory.mock.responseText = 'down';
|
||||
factory.mock.mockDownloadProgressEvent(100, 300);
|
||||
factory.mock.responseText = 'download';
|
||||
@ -176,70 +179,78 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||
factory.mock.mockFlush(200, 'OK', 'downloaded');
|
||||
});
|
||||
it('are emitted for upload progress', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST.clone({reportProgress: true})).toArray().subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.UploadProgress,
|
||||
HttpEventType.UploadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
const [progress1, progress2] = [
|
||||
events[1] as HttpUploadProgressEvent,
|
||||
events[2] as HttpUploadProgressEvent,
|
||||
];
|
||||
expect(progress1.loaded).toBe(100);
|
||||
expect(progress1.total).toBe(300);
|
||||
expect(progress2.loaded).toBe(200);
|
||||
expect(progress2.total).toBe(300);
|
||||
done();
|
||||
});
|
||||
backend.handle(TEST_POST.clone({reportProgress: true}))
|
||||
.pipe(toArray())
|
||||
.subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.UploadProgress,
|
||||
HttpEventType.UploadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
const [progress1, progress2] = [
|
||||
events[1] as HttpUploadProgressEvent,
|
||||
events[2] as HttpUploadProgressEvent,
|
||||
];
|
||||
expect(progress1.loaded).toBe(100);
|
||||
expect(progress1.total).toBe(300);
|
||||
expect(progress2.loaded).toBe(200);
|
||||
expect(progress2.total).toBe(300);
|
||||
done();
|
||||
});
|
||||
factory.mock.mockUploadProgressEvent(100, 300);
|
||||
factory.mock.mockUploadProgressEvent(200, 300);
|
||||
factory.mock.mockFlush(200, 'OK', 'Done');
|
||||
});
|
||||
it('are emitted when both upload and download progress are available', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST.clone({reportProgress: true})).toArray().subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.UploadProgress,
|
||||
HttpEventType.ResponseHeader,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
done();
|
||||
});
|
||||
backend.handle(TEST_POST.clone({reportProgress: true}))
|
||||
.pipe(toArray())
|
||||
.subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.UploadProgress,
|
||||
HttpEventType.ResponseHeader,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
done();
|
||||
});
|
||||
factory.mock.mockUploadProgressEvent(100, 300);
|
||||
factory.mock.mockDownloadProgressEvent(200, 300);
|
||||
factory.mock.mockFlush(200, 'OK', 'Done');
|
||||
});
|
||||
it('are emitted even if length is not computable', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST.clone({reportProgress: true})).toArray().subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.UploadProgress,
|
||||
HttpEventType.ResponseHeader,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
done();
|
||||
});
|
||||
backend.handle(TEST_POST.clone({reportProgress: true}))
|
||||
.pipe(toArray())
|
||||
.subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.UploadProgress,
|
||||
HttpEventType.ResponseHeader,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
done();
|
||||
});
|
||||
factory.mock.mockUploadProgressEvent(100);
|
||||
factory.mock.mockDownloadProgressEvent(200);
|
||||
factory.mock.mockFlush(200, 'OK', 'Done');
|
||||
});
|
||||
it('include ResponseHeader with headers and status', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST.clone({reportProgress: true})).toArray().subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.ResponseHeader,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
const partial = events[1] as HttpHeaderResponse;
|
||||
expect(partial.headers.get('Content-Type')).toEqual('text/plain');
|
||||
expect(partial.headers.get('Test')).toEqual('Test header');
|
||||
done();
|
||||
});
|
||||
backend.handle(TEST_POST.clone({reportProgress: true}))
|
||||
.pipe(toArray())
|
||||
.subscribe(events => {
|
||||
expect(events.map(event => event.type)).toEqual([
|
||||
HttpEventType.Sent,
|
||||
HttpEventType.ResponseHeader,
|
||||
HttpEventType.DownloadProgress,
|
||||
HttpEventType.Response,
|
||||
]);
|
||||
const partial = events[1] as HttpHeaderResponse;
|
||||
expect(partial.headers.get('Content-Type')).toEqual('text/plain');
|
||||
expect(partial.headers.get('Test')).toEqual('Test header');
|
||||
done();
|
||||
});
|
||||
factory.mock.mockResponseHeaders = 'Test: Test header\nContent-Type: text/plain\n';
|
||||
factory.mock.mockDownloadProgressEvent(200);
|
||||
factory.mock.mockFlush(200, 'OK', 'Done');
|
||||
@ -251,18 +262,20 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||
expect(factory.mock.listeners.progress).toBeUndefined();
|
||||
});
|
||||
it('do not cause headers to be re-parsed on main response', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST.clone({reportProgress: true})).toArray().subscribe(events => {
|
||||
events
|
||||
.filter(
|
||||
event => event.type === HttpEventType.Response ||
|
||||
event.type === HttpEventType.ResponseHeader)
|
||||
.map(event => event as HttpResponseBase)
|
||||
.forEach(event => {
|
||||
expect(event.status).toBe(203);
|
||||
expect(event.headers.get('Test')).toEqual('This is a test');
|
||||
});
|
||||
done();
|
||||
});
|
||||
backend.handle(TEST_POST.clone({reportProgress: true}))
|
||||
.pipe(toArray())
|
||||
.subscribe(events => {
|
||||
events
|
||||
.filter(
|
||||
event => event.type === HttpEventType.Response ||
|
||||
event.type === HttpEventType.ResponseHeader)
|
||||
.map(event => event as HttpResponseBase)
|
||||
.forEach(event => {
|
||||
expect(event.status).toBe(203);
|
||||
expect(event.headers.get('Test')).toEqual('This is a test');
|
||||
});
|
||||
done();
|
||||
});
|
||||
factory.mock.mockResponseHeaders = 'Test: This is a test\n';
|
||||
factory.mock.status = 203;
|
||||
factory.mock.mockDownloadProgressEvent(100, 300);
|
||||
@ -272,7 +285,7 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||
});
|
||||
describe('gets response URL', () => {
|
||||
it('from XHR.responsesURL', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST).toArray().subscribe(events => {
|
||||
backend.handle(TEST_POST).pipe(toArray()).subscribe(events => {
|
||||
expect(events.length).toBe(2);
|
||||
expect(events[1].type).toBe(HttpEventType.Response);
|
||||
const response = events[1] as HttpResponse<string>;
|
||||
@ -283,7 +296,7 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||
factory.mock.mockFlush(200, 'OK', 'Test');
|
||||
});
|
||||
it('from X-Request-URL header if XHR.responseURL is not present', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST).toArray().subscribe(events => {
|
||||
backend.handle(TEST_POST).pipe(toArray()).subscribe(events => {
|
||||
expect(events.length).toBe(2);
|
||||
expect(events[1].type).toBe(HttpEventType.Response);
|
||||
const response = events[1] as HttpResponse<string>;
|
||||
@ -294,7 +307,7 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||
factory.mock.mockFlush(200, 'OK', 'Test');
|
||||
});
|
||||
it('falls back on Request.url if neither are available', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST).toArray().subscribe(events => {
|
||||
backend.handle(TEST_POST).pipe(toArray()).subscribe(events => {
|
||||
expect(events.length).toBe(2);
|
||||
expect(events[1].type).toBe(HttpEventType.Response);
|
||||
const response = events[1] as HttpResponse<string>;
|
||||
@ -306,7 +319,7 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||
});
|
||||
describe('corrects for quirks', () => {
|
||||
it('by normalizing 1223 status to 204', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST).toArray().subscribe(events => {
|
||||
backend.handle(TEST_POST).pipe(toArray()).subscribe(events => {
|
||||
expect(events.length).toBe(2);
|
||||
expect(events[1].type).toBe(HttpEventType.Response);
|
||||
const response = events[1] as HttpResponse<string>;
|
||||
@ -316,7 +329,7 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||
factory.mock.mockFlush(1223, 'IE Special Status', 'Test');
|
||||
});
|
||||
it('by normalizing 0 status to 200 if a body is present', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST).toArray().subscribe(events => {
|
||||
backend.handle(TEST_POST).pipe(toArray()).subscribe(events => {
|
||||
expect(events.length).toBe(2);
|
||||
expect(events[1].type).toBe(HttpEventType.Response);
|
||||
const response = events[1] as HttpResponse<string>;
|
||||
@ -326,10 +339,11 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||
factory.mock.mockFlush(0, 'CORS 0 status', 'Test');
|
||||
});
|
||||
it('by leaving 0 status as 0 if a body is not present', (done: DoneFn) => {
|
||||
backend.handle(TEST_POST).toArray().subscribe(undefined, (error: HttpErrorResponse) => {
|
||||
expect(error.status).toBe(0);
|
||||
done();
|
||||
});
|
||||
backend.handle(TEST_POST).pipe(toArray()).subscribe(
|
||||
undefined, (error: HttpErrorResponse) => {
|
||||
expect(error.status).toBe(0);
|
||||
done();
|
||||
});
|
||||
factory.mock.mockFlush(0, 'CORS 0 status');
|
||||
});
|
||||
});
|
||||
|
@ -14,12 +14,8 @@ const globals = {
|
||||
'@angular/platform-browser': 'ng.platformBrowser',
|
||||
'@angular/common': 'ng.common',
|
||||
'@angular/common/http': 'ng.common.http',
|
||||
'rxjs/Observable': 'Rx',
|
||||
'rxjs/Observer': 'Rx',
|
||||
'rxjs/ReplaySubject': 'Rx',
|
||||
'rxjs/Subject': 'Rx',
|
||||
|
||||
'rxjs/operator/startWith': 'Rx.Observable.prototype',
|
||||
'rxjs': 'rxjs',
|
||||
'rxjs/operators': 'rxjs.operators',
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -8,9 +8,7 @@
|
||||
|
||||
import {HttpBackend, HttpEvent, HttpEventType, HttpRequest} from '@angular/common/http';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observer} from 'rxjs/Observer';
|
||||
import {startWith} from 'rxjs/operator/startWith';
|
||||
import {Observable, Observer} from 'rxjs';
|
||||
|
||||
import {HttpTestingController, RequestMatch} from './api';
|
||||
import {TestRequest} from './request';
|
||||
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {HttpErrorResponse, HttpEvent, HttpEventType, HttpHeaders, HttpRequest, HttpResponse} from '@angular/common/http';
|
||||
import {Observer} from 'rxjs/Observer';
|
||||
import {HttpErrorResponse, HttpEvent, HttpHeaders, HttpRequest, HttpResponse} from '@angular/common/http';
|
||||
import {Observer} from 'rxjs';
|
||||
|
||||
/**
|
||||
* A mock requests that was received and is ready to be answered.
|
||||
|
@ -17,7 +17,7 @@
|
||||
},
|
||||
"locales": "locales",
|
||||
"peerDependencies": {
|
||||
"rxjs": "^5.5.0",
|
||||
"rxjs": "^6.0.0-alpha.3",
|
||||
"@angular/core": "0.0.0-PLACEHOLDER"
|
||||
},
|
||||
"repository": {
|
||||
|
@ -11,10 +11,7 @@ const sourcemaps = require('rollup-plugin-sourcemaps');
|
||||
|
||||
const globals = {
|
||||
'@angular/core': 'ng.core',
|
||||
'rxjs/Observable': 'Rx',
|
||||
'rxjs/Observer': 'Rx',
|
||||
'rxjs/Subject': 'Rx',
|
||||
'rxjs/Subscription': 'Rx',
|
||||
'rxjs': 'rxjs',
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {EventEmitter, Injectable} from '@angular/core';
|
||||
import {ISubscription} from 'rxjs/Subscription';
|
||||
import {SubscriptionLike} from 'rxjs';
|
||||
|
||||
import {LocationStrategy} from './location_strategy';
|
||||
|
||||
@ -132,7 +132,7 @@ export class Location {
|
||||
*/
|
||||
subscribe(
|
||||
onNext: (value: PopStateEvent) => void, onThrow?: ((exception: any) => void)|null,
|
||||
onReturn?: (() => void)|null): ISubscription {
|
||||
onReturn?: (() => void)|null): SubscriptionLike {
|
||||
return this._subject.subscribe({next: onNext, error: onThrow, complete: onReturn});
|
||||
}
|
||||
|
||||
|
@ -7,25 +7,24 @@
|
||||
*/
|
||||
|
||||
import {ChangeDetectorRef, EventEmitter, OnDestroy, Pipe, PipeTransform, WrappedValue, ɵisObservable, ɵisPromise} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {ISubscription} from 'rxjs/Subscription';
|
||||
import {Observable, SubscriptionLike} from 'rxjs';
|
||||
import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
|
||||
|
||||
interface SubscriptionStrategy {
|
||||
createSubscription(async: Observable<any>|Promise<any>, updateLatestValue: any): ISubscription
|
||||
createSubscription(async: Observable<any>|Promise<any>, updateLatestValue: any): SubscriptionLike
|
||||
|Promise<any>;
|
||||
dispose(subscription: ISubscription|Promise<any>): void;
|
||||
onDestroy(subscription: ISubscription|Promise<any>): void;
|
||||
dispose(subscription: SubscriptionLike|Promise<any>): void;
|
||||
onDestroy(subscription: SubscriptionLike|Promise<any>): void;
|
||||
}
|
||||
|
||||
class ObservableStrategy implements SubscriptionStrategy {
|
||||
createSubscription(async: Observable<any>, updateLatestValue: any): ISubscription {
|
||||
createSubscription(async: Observable<any>, updateLatestValue: any): SubscriptionLike {
|
||||
return async.subscribe({next: updateLatestValue, error: (e: any) => { throw e; }});
|
||||
}
|
||||
|
||||
dispose(subscription: ISubscription): void { subscription.unsubscribe(); }
|
||||
dispose(subscription: SubscriptionLike): void { subscription.unsubscribe(); }
|
||||
|
||||
onDestroy(subscription: ISubscription): void { subscription.unsubscribe(); }
|
||||
onDestroy(subscription: SubscriptionLike): void { subscription.unsubscribe(); }
|
||||
}
|
||||
|
||||
class PromiseStrategy implements SubscriptionStrategy {
|
||||
@ -71,7 +70,7 @@ export class AsyncPipe implements OnDestroy, PipeTransform {
|
||||
private _latestValue: any = null;
|
||||
private _latestReturnedValue: any = null;
|
||||
|
||||
private _subscription: ISubscription|Promise<any>|null = null;
|
||||
private _subscription: SubscriptionLike|Promise<any>|null = null;
|
||||
private _obj: Observable<any>|Promise<any>|EventEmitter<any>|null = null;
|
||||
private _strategy: SubscriptionStrategy = null !;
|
||||
|
||||
|
@ -12,9 +12,7 @@ const sourcemaps = require('rollup-plugin-sourcemaps');
|
||||
const globals = {
|
||||
'@angular/core': 'ng.core',
|
||||
'@angular/common': 'ng.common',
|
||||
'rxjs/Observable': 'Rx',
|
||||
'rxjs/Subject': 'Rx',
|
||||
'rxjs/Subscription': 'Rx'
|
||||
'rxjs': 'rxjs',
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {Location, LocationStrategy} from '@angular/common';
|
||||
import {EventEmitter, Injectable} from '@angular/core';
|
||||
import {ISubscription} from 'rxjs/Subscription';
|
||||
import {SubscriptionLike} from 'rxjs';
|
||||
|
||||
|
||||
/**
|
||||
@ -113,7 +113,7 @@ export class SpyLocation implements Location {
|
||||
|
||||
subscribe(
|
||||
onNext: (value: any) => void, onThrow?: ((error: any) => void)|null,
|
||||
onReturn?: (() => void)|null): ISubscription {
|
||||
onReturn?: (() => void)|null): SubscriptionLike {
|
||||
return this._subject.subscribe({next: onNext, error: onThrow, complete: onReturn});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user