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

@ -13,8 +13,7 @@ const globals = {
'@angular/core': 'ng.core',
'@angular/animations': 'ng.animations',
'@angular/animations/browser': 'ng.animations.browser',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs': 'rxjs',
};
module.exports = {

View File

@ -12,8 +12,7 @@ const sourcemaps = require('rollup-plugin-sourcemaps');
const globals = {
'@angular/core': 'ng.core',
'@angular/animations': 'ng.animations',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs': 'rxjs',
};
module.exports = {

View File

@ -28,157 +28,9 @@ WELL_KNOWN_GLOBALS = {
"@angular/platform-browser": "ng.platformBrowser",
"@angular/platform-browser/testing": "ng.platformBrowser.testing",
"@angular/platform-browser-dynamic": "ng.platformBrowserDynamic",
"rxjs": "rxjs",
"rxjs/operators": "rxjs.operators",
}
WELL_KNOWN_GLOBALS.update({"rxjs/%s" % s: "Rx" for s in [
"BehaviorSubject",
"ConnectableObservable",
"Observable",
"Observer",
"ReplaySubject",
"Scheduler",
"Subject",
"Subscriber",
"Subscription",
"util/EmptyError",
]})
WELL_KNOWN_GLOBALS.update({"rxjs/observable/%s" % s: "Rx.Observable" for s in [
"combineLatest",
"concat",
"defer",
"empty",
"forkJoin",
"from",
"fromEvent",
"fromEventPattern",
"fromPromise",
"merge",
"never",
"of",
"throw",
]})
WELL_KNOWN_GLOBALS.update({"rxjs/operator/%s" % s: "Rx.Observable.prototype" for s in [
"catch",
"concatAll",
"concatMap",
"do",
"every",
"first",
"filter",
"last",
"map",
"mergeAll",
"mergeMap",
"publish",
"reduce",
"share",
"startWith",
"switchMap",
"take",
"toPromise",
]})
WELL_KNOWN_GLOBALS.update({"rxjs/operators/%s" % s: "Rx.operators" for s in [
"audit",
"auditTime",
"bufferCount",
"buffer",
"bufferTime",
"bufferToggle",
"bufferWhen",
"catchError",
"combineAll",
"combineLatest",
"concatAll",
"concat",
"concatMap",
"concatMapTo",
"count",
"debounce",
"debounceTime",
"defaultIfEmpty",
"delay",
"delayWhen",
"dematerialize",
"distinct",
"distinctUntilChanged",
"distinctUntilKeyChanged",
"elementAt",
"every",
"exhaust",
"exhaustMap",
"expand",
"filter",
"finalize",
"findIndex",
"find",
"first",
"groupBy",
"ignoreElements",
"isEmpty",
"last",
"map",
"mapTo",
"materialize",
"max",
"mergeAll",
"merge",
"mergeMap",
"mergeMapTo",
"mergeScan",
"min",
"multicast",
"observeOn",
"onErrorResumeNext",
"pairwise",
"partition",
"pluck",
"publishBehavior",
"publish",
"publishLast",
"publishReplay",
"race",
"reduce",
"refCount",
"repeat",
"repeatWhen",
"retry",
"retryWhen",
"sample",
"sampleTime",
"scan",
"sequenceEqual",
"share",
"shareReplay",
"single",
"skip",
"skipLast",
"skipUntil",
"skipWhile",
"startWith",
"subscribeOn",
"switchAll",
"switchMap",
"switchMapTo",
"take",
"takeLast",
"takeUntil",
"takeWhile",
"tap",
"throttle",
"throttleTime",
"timeInterval",
"timeout",
"timeoutWith",
"timestamp",
"toArray",
"windowCount",
"window",
"windowTime",
"windowToggle",
"windowWhen",
"withLatestFrom",
"zipAll",
"zip",
]})
def _rollup(ctx, rollup_config, entry_point, inputs, js_output, format = "es"):

View File

@ -8,7 +8,7 @@
"dependencies": {
"@angular/core": "^2.0.0-rc.7",
"reflect-metadata": "^0.1.2",
"rxjs": "^5.5.0",
"rxjs": "^6.0.0-alpha.3",
"jpm": "1.1.4",
"firefox-profile": "0.4.0",
"selenium-webdriver": "^2.53.3"

View File

@ -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 = {

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';

View File

@ -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);

View File

@ -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();

View File

@ -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;
});
}));
}
}

View File

@ -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');
});
});

View File

@ -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 = {

View File

@ -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';

View File

@ -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.

View File

@ -17,7 +17,7 @@
},
"locales": "locales",
"peerDependencies": {
"rxjs": "^5.5.0",
"rxjs": "^6.0.0-alpha.3",
"@angular/core": "0.0.0-PLACEHOLDER"
},
"repository": {

View File

@ -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 = {

View File

@ -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});
}

View File

@ -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 !;

View File

@ -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 = {

View File

@ -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});
}

View File

@ -8,7 +8,7 @@
import * as common from '@angular/common';
import {CUSTOM_ELEMENTS_SCHEMA, Component, Directive, EventEmitter, Inject, InjectionToken, NgModule, Output, forwardRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {wrapInArray} from './funcs';

View File

@ -11,8 +11,7 @@ const sourcemaps = require('rollup-plugin-sourcemaps');
const globals = {
'@angular/core': 'ng.core',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs': 'rxjs',
};
module.exports = {

View File

@ -60,6 +60,8 @@ export interface EmitterOptions {
function calcPathsOnDisc() {
const moduleFilename = module.filename.replace(/\\/g, '/');
// TODO(i): this is suspicious because it relies on build.sh output
// which is problematic when we are running tests under bazel - review with Chuck
const distIndex = moduleFilename.indexOf('/dist/all');
if (distIndex >= 0) {
rootPath = moduleFilename.substr(0, distIndex);

View File

@ -13,8 +13,7 @@ const globals = {
'@angular/core': 'ng.core',
'@angular/core/testing': 'ng.core.testing',
'@angular/compiler': 'ng.compiler',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx'
'rxjs': 'rxjs',
};
module.exports = {

View File

@ -16,7 +16,7 @@
"tslib": "^1.9.0"
},
"peerDependencies": {
"rxjs": "^5.5.0",
"rxjs": "^6.0.0-alpha.3",
"zone.js": "^0.8.4"
},
"repository": {

View File

@ -10,12 +10,8 @@ const resolve = require('rollup-plugin-node-resolve');
const sourcemaps = require('rollup-plugin-sourcemaps');
const globals = {
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs/Observer': 'Rx',
'rxjs/Subscription': 'Rx',
'rxjs/observable/merge': 'Rx.Observable',
'rxjs/operator/share': 'Rx.Observable.prototype'
'rxjs': 'rxjs',
'rxjs/operators': 'rxjs.operators'
};
module.exports = {

View File

@ -6,11 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import {Subscription} from 'rxjs/Subscription';
import {merge} from 'rxjs/observable/merge';
import {share} from 'rxjs/operator/share';
import {Observable, Observer, Subscription, merge} from 'rxjs';
import {share} from 'rxjs/operators';
import {ErrorHandler} from '../src/error_handler';
import {scheduleMicroTask, stringify} from '../src/util';
@ -445,7 +442,7 @@ export class ApplicationRef {
});
(this as{isStable: Observable<boolean>}).isStable =
merge(isCurrentlyStable, share.call(isStable));
merge(isCurrentlyStable, isStable.pipe(share()));
}
/**

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Subject} from 'rxjs/Subject';
import {Subscription} from 'rxjs/Subscription';
import {Subject, Subscription} from 'rxjs';
/**
* Use by directives and components to emit custom Events.

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 {EventEmitter} from '../event_emitter';
import {getSymbolIterator} from '../util';

View File

@ -8,7 +8,7 @@
// We are temporarily importing the existing viewEngine_from core so we can be sure we are
// correctly implementing its interfaces for backwards compatibility.
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {EventEmitter} from '../event_emitter';
import {QueryList as viewEngine_QueryList} from '../linker/query_list';

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';
/**
* Determine if the argument is shaped like a Promise

View File

@ -1,9 +1,24 @@
[
{
"name": "Action"
},
{
"name": "AnimationFrameAction"
},
{
"name": "AsapAction"
},
{
"name": "AsyncAction"
},
{
"name": "AsyncScheduler"
},
{
"name": "CLEAN_PROMISE"
},
{
"name": "EMPTY$1"
"name": "EMPTY$2"
},
{
"name": "EMPTY_RENDERER_TYPE_ID"
@ -14,6 +29,9 @@
{
"name": "INeedToExistEvenThoughtIAmNotNeeded"
},
{
"name": "Immediate"
},
{
"name": "NG_HOST_SYMBOL"
},
@ -21,26 +39,65 @@
"name": "NG_PROJECT_AS_ATTR_NAME"
},
{
"name": "Symbol$1"
"name": "Observable"
},
{
"name": "QueueAction"
},
{
"name": "SafeSubscriber"
},
{
"name": "Scheduler"
},
{
"name": "Subscriber"
},
{
"name": "Subscription"
},
{
"name": "UNDEFINED_RENDERER_TYPE_ID"
},
{
"name": "__global$1"
"name": "UnsubscriptionError"
},
{
"name": "__self$1"
"name": "__extends$1"
},
{
"name": "__window$1"
"name": "__extends$10"
},
{
"name": "__extends$11"
},
{
"name": "__extends$12"
},
{
"name": "__extends$13"
},
{
"name": "__extends$14"
},
{
"name": "__extends$17"
},
{
"name": "__extends$18"
},
{
"name": "__extends$19"
},
{
"name": "__extends$2"
},
{
"name": "__extends$20"
},
{
"name": "_renderCompCount"
},
{
"name": "_root"
},
{
"name": "appendChild"
},
@ -59,6 +116,9 @@
{
"name": "componentRefresh"
},
{
"name": "config"
},
{
"name": "createLNode"
},
@ -83,9 +143,15 @@
{
"name": "domRendererFactory3"
},
{
"name": "empty"
},
{
"name": "enterView"
},
{
"name": "errorObject"
},
{
"name": "executeHooks"
},
@ -95,6 +161,9 @@
{
"name": "executeInitHooks"
},
{
"name": "flattenUnsubscriptionErrors"
},
{
"name": "getDirectiveInstance"
},
@ -102,7 +171,10 @@
"name": "getOrCreateTView"
},
{
"name": "getSymbolObservable"
"name": "getPromiseCtor"
},
{
"name": "getSymbolIterator$1"
},
{
"name": "hostElement"
@ -113,6 +185,15 @@
{
"name": "invertObject"
},
{
"name": "isArray"
},
{
"name": "isFunction"
},
{
"name": "isObject"
},
{
"name": "isProceduralRenderer"
},
@ -122,6 +203,18 @@
{
"name": "locateHostElement"
},
{
"name": "nextHandle"
},
{
"name": "noop"
},
{
"name": "observable"
},
{
"name": "pipeFromArray"
},
{
"name": "refreshChildComponents"
},
@ -149,6 +242,12 @@
{
"name": "rootDirectiveIndices"
},
{
"name": "runIfPresent"
},
{
"name": "rxSubscriber"
},
{
"name": "setHostBindings"
},
@ -159,11 +258,20 @@
"name": "stringify$1"
},
{
"name": "symbolIteratorPonyfill"
"name": "tasksByHandle"
},
{
"name": "text"
},
{
"name": "toSubscriber"
},
{
"name": "tryCatch"
},
{
"name": "tryCatcher"
},
{
"name": "viewAttached"
}

View File

@ -18,6 +18,14 @@ const PACKAGE = 'angular/packages/core/test/bundling/hello_world';
import * as domino from 'domino';
describe('treeshaking with uglify', () => {
beforeAll(() => {
// initialize window so that when rxjs is loaded it is loaded and initialized as if it was
// loaded in a browser
// even when the test runs in node
(global as any).window = domino.createWindow('', 'http://localhost');
});
let content: string;
const contentPath = require.resolve(path.join(PACKAGE, 'bundle.min_debug.js'));
beforeAll(() => { content = fs.readFileSync(contentPath, UTF8); });
@ -51,4 +59,4 @@ describe('treeshaking with uglify', () => {
expect(document.body.textContent).toEqual('Hello World!');
}));
});
});
});

View File

@ -2,6 +2,21 @@
{
"name": "APP_ROOT"
},
{
"name": "Action"
},
{
"name": "AnimationFrameAction"
},
{
"name": "AsapAction"
},
{
"name": "AsyncAction"
},
{
"name": "AsyncScheduler"
},
{
"name": "CIRCULAR$1"
},
@ -14,6 +29,9 @@
{
"name": "INJECTOR$1"
},
{
"name": "Immediate"
},
{
"name": "Inject"
},
@ -29,15 +47,27 @@
{
"name": "NullInjector"
},
{
"name": "Observable"
},
{
"name": "Optional"
},
{
"name": "PARAMETERS"
},
{
"name": "QueueAction"
},
{
"name": "R3Injector"
},
{
"name": "SafeSubscriber"
},
{
"name": "Scheduler"
},
{
"name": "ScopedService"
},
@ -48,7 +78,10 @@
"name": "SkipSelf"
},
{
"name": "Symbol$1"
"name": "Subscriber"
},
{
"name": "Subscription"
},
{
"name": "THROW_IF_NOT_FOUND"
@ -56,29 +89,56 @@
{
"name": "USE_VALUE$1"
},
{
"name": "UnsubscriptionError"
},
{
"name": "_THROW_IF_NOT_FOUND"
},
{
"name": "__global$1"
"name": "__extends$1"
},
{
"name": "__extends$10"
},
{
"name": "__extends$11"
},
{
"name": "__extends$12"
},
{
"name": "__extends$13"
},
{
"name": "__extends$14"
},
{
"name": "__extends$17"
},
{
"name": "__extends$18"
},
{
"name": "__extends$19"
},
{
"name": "__extends$2"
},
{
"name": "__extends$20"
},
{
"name": "__read"
},
{
"name": "__self$1"
},
{
"name": "__spread"
},
{
"name": "__window$1"
},
{
"name": "_currentInjector"
},
{
"name": "_root"
"name": "config"
},
{
"name": "couldBeInjectableType"
@ -95,6 +155,15 @@
{
"name": "defineInjector"
},
{
"name": "empty"
},
{
"name": "errorObject"
},
{
"name": "flattenUnsubscriptionErrors"
},
{
"name": "forwardRef"
},
@ -105,7 +174,10 @@
"name": "getNullInjector"
},
{
"name": "getSymbolObservable"
"name": "getPromiseCtor"
},
{
"name": "getSymbolIterator$1"
},
{
"name": "hasDeps"
@ -122,12 +194,21 @@
{
"name": "injectableDefRecord"
},
{
"name": "isArray"
},
{
"name": "isExistingProvider"
},
{
"name": "isFactoryProvider"
},
{
"name": "isFunction"
},
{
"name": "isObject"
},
{
"name": "isTypeProvider"
},
@ -143,12 +224,30 @@
{
"name": "makeRecord"
},
{
"name": "nextHandle"
},
{
"name": "noop"
},
{
"name": "observable"
},
{
"name": "pipeFromArray"
},
{
"name": "providerToRecord"
},
{
"name": "resolveForwardRef"
},
{
"name": "runIfPresent"
},
{
"name": "rxSubscriber"
},
{
"name": "setCurrentInjector"
},
@ -156,6 +255,15 @@
"name": "stringify"
},
{
"name": "symbolIteratorPonyfill"
"name": "tasksByHandle"
},
{
"name": "toSubscriber"
},
{
"name": "tryCatch"
},
{
"name": "tryCatcher"
}
]

View File

@ -10,7 +10,7 @@ import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit,
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
import {expect} from '@angular/platform-browser/testing/src/matchers';
import {Subject} from 'rxjs/Subject';
import {Subject} from 'rxjs';
import {stringify} from '../../src/util';

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {isObservable, isPromise} from '@angular/core/src/util/lang';
import {of } from 'rxjs/observable/of';
import {of } from 'rxjs';
{
describe('isPromise', () => {

View File

@ -11,8 +11,7 @@ const sourcemaps = require('rollup-plugin-sourcemaps');
const globals = {
'@angular/core': 'ng.core',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs': 'rxjs',
};
module.exports = {

View File

@ -12,10 +12,8 @@ const sourcemaps = require('rollup-plugin-sourcemaps');
const globals = {
'@angular/core': 'ng.core',
'@angular/platform-browser': 'ng.platformBrowser',
'rxjs/Subscription': 'Rx',
'rxjs/Observable': 'Rx',
'rxjs/observable/merge': 'Rx.Observable',
'rxjs/operator/map': 'Rx.Observable.prototype'
'rxjs': 'rxjs',
'rxjs/operators': 'rxjs.operators'
};
module.exports = {

View File

@ -7,9 +7,8 @@
*/
import {ApplicationRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, EventEmitter, Injector, OnChanges, SimpleChange, SimpleChanges, Type} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {merge} from 'rxjs/observable/merge';
import {map} from 'rxjs/operator/map';
import {Observable, merge} from 'rxjs';
import {map} from 'rxjs/operators';
import {NgElementStrategy, NgElementStrategyEvent, NgElementStrategyFactory} from './element-strategy';
import {extractProjectableNodes} from './extract-projectable-nodes';
@ -180,7 +179,7 @@ export class ComponentNgElementStrategy implements NgElementStrategy {
protected initializeOutputs(): void {
const eventEmitters = this.componentFactory.outputs.map(({propName, templateName}) => {
const emitter = (this.componentRef !.instance as any)[propName] as EventEmitter<any>;
return map.call(emitter, (value: any) => ({name: templateName, value}));
return emitter.pipe(map((value: any) => ({name: templateName, value})));
});
this.events = merge(...eventEmitters);

View File

@ -7,7 +7,7 @@
*/
import {Injector, Type} from '@angular/core';
import {Subscription} from 'rxjs/Subscription';
import {Subscription} from 'rxjs';
import {ComponentNgElementStrategyFactory} from './component-factory-strategy';
import {NgElementStrategy, NgElementStrategyFactory} from './element-strategy';

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {ComponentFactory, Injector} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
/**
* Interface for the events emitted through the NgElementStrategy.

View File

@ -8,7 +8,7 @@
import {ComponentFactory, ComponentRef, Injector, NgModuleRef, SimpleChange, SimpleChanges, Type} from '@angular/core';
import {fakeAsync, tick} from '@angular/core/testing';
import {Subject} from 'rxjs/Subject';
import {Subject} from 'rxjs';
import {ComponentNgElementStrategy, ComponentNgElementStrategyFactory} from '../src/component-factory-strategy';
import {NgElementStrategyEvent} from '../src/element-strategy';

View File

@ -9,7 +9,7 @@
import {Component, EventEmitter, Injector, Input, NgModule, Output, destroyPlatform} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {Subject} from 'rxjs/Subject';
import {Subject} from 'rxjs';
import {NgElementConstructor, createCustomElement} from '../src/create-custom-element';
import {NgElementStrategy, NgElementStrategyEvent, NgElementStrategyFactory} from '../src/element-strategy';

View File

@ -24,10 +24,13 @@ System.config({
'@angular/router': '/vendor/@angular/router/bundles/router.umd.js',
'@angular/upgrade': '/vendor/@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': '/vendor/@angular/upgrade/bundles/upgrade-static.umd.js',
'rxjs': '/vendor/rxjs',
'rxjs': '/vendor/rxjs'
},
packages: {
// rxjs: {format: 'cjs', exports: 'Rx' }
rxjs: {defaultExtension: 'js'}
}
'rxjs/ajax': {main: 'index.js', defaultExtension: 'js'},
'rxjs/operators': {main: 'index.js', defaultExtension: 'js'},
'rxjs/testing': {main: 'index.js', defaultExtension: 'js'},
'rxjs/websocket': {main: 'index.js', defaultExtension: 'js'},
'rxjs': {main: 'index.js', defaultExtension: 'js'},
},
});

View File

@ -8,7 +8,7 @@
import {Component, NgModule, OnInit, TemplateRef, ViewChild} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {Subject} from 'rxjs/Subject';
import {Subject} from 'rxjs';
// #docregion NgIfSimple

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, NgModule, OnInit, TemplateRef, ViewChild} from '@angular/core';
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {Subject} from 'rxjs/Subject';
// #docregion NgTemplateOutlet

View File

@ -7,8 +7,7 @@
*/
import {Component} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Subscriber} from 'rxjs/Subscriber';
import {Observable, Observer} from 'rxjs';
// #docregion AsyncPipePromise
@Component({
@ -49,7 +48,7 @@ export class AsyncPromisePipeComponent {
template: '<div><code>observable|async</code>: Time: {{ time | async }}</div>'
})
export class AsyncObservablePipeComponent {
time = new Observable<string>((observer: Subscriber<string>) => {
time = new Observable<string>((observer: Observer<string>) => {
setInterval(() => observer.next(new Date().toString()), 1000);
});
}

View File

@ -16,7 +16,7 @@
"tslib": "^1.9.0"
},
"peerDependencies": {
"rxjs": "^5.5.0",
"rxjs": "^6.0.0-alpha.3",
"@angular/core": "0.0.0-PLACEHOLDER",
"@angular/common": "0.0.0-PLACEHOLDER",
"@angular/platform-browser": "0.0.0-PLACEHOLDER"

View File

@ -14,11 +14,8 @@ const globals = {
'@angular/common': 'ng.common',
'@angular/compiler': 'ng.compiler',
'@angular/platform-browser': 'ng.platformBrowser',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs/observable/fromPromise': 'Rx.Observable',
'rxjs/observable/forkJoin': 'Rx.Observable',
'rxjs/operator/map': 'Rx.Observable.prototype'
'rxjs': 'rxjs',
'rxjs/operators': 'rxjs.operators',
};
module.exports = {

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 {AbstractControl} from '../model';
import {ValidationErrors} from './validators';

View File

@ -7,7 +7,7 @@
*/
import {Directive, Input, OnChanges, SimpleChanges, StaticProvider, forwardRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {AbstractControl} from '../model';
import {NG_VALIDATORS, Validators} from '../validators';

View File

@ -7,7 +7,7 @@
*/
import {EventEmitter} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {composeAsyncValidators, composeValidators} from './directives/shared';
import {AsyncValidatorFn, ValidationErrors, ValidatorFn} from './directives/validators';
import {toObservable} from './validators';

View File

@ -7,10 +7,8 @@
*/
import {InjectionToken, ɵisObservable as isObservable, ɵisPromise as isPromise} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {forkJoin} from 'rxjs/observable/forkJoin';
import {fromPromise} from 'rxjs/observable/fromPromise';
import {map} from 'rxjs/operator/map';
import {Observable, forkJoin, from} from 'rxjs';
import {map} from 'rxjs/operators';
import {AsyncValidatorFn, ValidationErrors, Validator, ValidatorFn} from './directives/validators';
import {AbstractControl, FormControl} from './model';
@ -217,7 +215,7 @@ export class Validators {
return function(control: AbstractControl) {
const observables = _executeAsyncValidators(control, presentValidators).map(toObservable);
return map.call(forkJoin(observables), _mergeErrors);
return forkJoin(observables).pipe(map(_mergeErrors));
};
}
}
@ -227,7 +225,7 @@ function isPresent(o: any): boolean {
}
export function toObservable(r: any): Observable<any> {
const obs = isPromise(r) ? fromPromise(r) : r;
const obs = isPromise(r) ? from(r) : r;
if (!(isObservable(obs))) {
throw new Error(`Expected validator to return Promise or Observable.`);
}

View File

@ -10,7 +10,7 @@ import {fakeAsync, tick} from '@angular/core/testing';
import {AsyncTestCompleter, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
import {AbstractControl, FormArray, FormControl, FormGroup, ValidationErrors} from '@angular/forms';
import {Validators} from '@angular/forms/src/validators';
import {of } from 'rxjs/observable/of';
import {of } from 'rxjs';
(function() {
function asyncValidator(expected: string, timeouts = {}) {

View File

@ -8,7 +8,7 @@
import {fakeAsync, tick} from '@angular/core/testing';
import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal';
import {FormBuilder} from '@angular/forms';
import {of } from 'rxjs/observable/of';
import {of } from 'rxjs';
(function() {
function syncValidator(_: any /** TODO #9100 */): any /** TODO #9100 */ { return null; }

View File

@ -10,7 +10,7 @@ import {EventEmitter} from '@angular/core';
import {async, fakeAsync, tick} from '@angular/core/testing';
import {AsyncTestCompleter, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
import {AbstractControl, FormArray, FormControl, FormGroup, ValidationErrors, Validators} from '@angular/forms';
import {of } from 'rxjs/observable/of';
import {of } from 'rxjs';
(function() {

View File

@ -12,9 +12,8 @@ import {AbstractControl, AsyncValidator, AsyncValidatorFn, COMPOSITION_BUFFER_MO
import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util';
import {merge} from 'rxjs/observable/merge';
import {timer} from 'rxjs/observable/timer';
import {_do} from 'rxjs/operator/do';
import {merge, timer} from 'rxjs';
import {tap} from 'rxjs/operators';
import {MyInput, MyInputForm} from './value_accessor_integration_spec';
@ -2433,7 +2432,7 @@ function uniqLoginAsyncValidator(expectedValue: string, timeout: number = 0) {
function observableValidator(resultArr: number[]): AsyncValidatorFn {
return (c: AbstractControl) => {
return _do.call(timer(100), (resp: any) => resultArr.push(resp));
return timer(100).pipe(tap((resp: any) => resultArr.push(resp)));
};
}

View File

@ -6,13 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, Directive, Type, ViewChild, forwardRef} from '@angular/core';
import {Component, Directive, Type, forwardRef} from '@angular/core';
import {ComponentFixture, TestBed, async, fakeAsync, tick} from '@angular/core/testing';
import {AbstractControl, AsyncValidator, COMPOSITION_BUFFER_MODE, FormControl, FormsModule, NG_ASYNC_VALIDATORS, NgForm, NgModel} from '@angular/forms';
import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util';
import {merge} from 'rxjs/observable/merge';
import {merge} from 'rxjs';
import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integration_spec';

View File

@ -11,11 +11,8 @@ import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
import {AbstractControl, AsyncValidatorFn, FormArray, FormControl, Validators} from '@angular/forms';
import {normalizeAsyncValidator} from '@angular/forms/src/directives/normalize_validator';
import {AsyncValidator, ValidationErrors, ValidatorFn} from '@angular/forms/src/directives/validators';
import {Observable} from 'rxjs/Observable';
import {of } from 'rxjs/observable/of';
import {timer} from 'rxjs/observable/timer';
import {first} from 'rxjs/operator/first';
import {map} from 'rxjs/operator/map';
import {Observable, of , timer} from 'rxjs';
import {first, map} from 'rxjs/operators';
(function() {
function validator(key: string, error: any): ValidatorFn {
@ -333,7 +330,8 @@ import {map} from 'rxjs/operator/map';
[promiseValidator({'one': true}), promiseValidator({'two': true})]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('invalid')))
(v(new FormControl('invalid')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
tick();
@ -345,7 +343,8 @@ import {map} from 'rxjs/operator/map';
new AsyncValidatorDirective('expected', {'one': true}))]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('invalid')))
(v(new FormControl('invalid')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
tick();
@ -356,7 +355,8 @@ import {map} from 'rxjs/operator/map';
const v = Validators.composeAsync([promiseValidator({'one': true})]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('expected')))
(v(new FormControl('expected')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
tick();
@ -367,7 +367,8 @@ import {map} from 'rxjs/operator/map';
const v = Validators.composeAsync([promiseValidator({'one': true}), null !]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('invalid')))
(v(new FormControl('invalid')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
tick();
@ -391,7 +392,8 @@ import {map} from 'rxjs/operator/map';
[observableValidator({'one': true}), observableValidator({'two': true})]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('invalid')))
(v(new FormControl('invalid')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
expect(errorMap).toEqual({'one': true, 'two': true});
@ -402,7 +404,8 @@ import {map} from 'rxjs/operator/map';
[normalizeAsyncValidator(new AsyncValidatorDirective('expected', {'one': true}))]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('invalid')))
(v(new FormControl('invalid')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors) !;
expect(errorMap).toEqual({'one': true});
@ -412,7 +415,8 @@ import {map} from 'rxjs/operator/map';
const v = Validators.composeAsync([observableValidator({'one': true})]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('expected')))
(v(new FormControl('expected')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
expect(errorMap).toBeNull();
@ -422,7 +426,8 @@ import {map} from 'rxjs/operator/map';
const v = Validators.composeAsync([observableValidator({'one': true}), null !]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('invalid')))
(v(new FormControl('invalid')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
expect(errorMap).toEqual({'one': true});
@ -430,14 +435,15 @@ import {map} from 'rxjs/operator/map';
it('should wait for all validators before setting errors', fakeAsync(() => {
function getTimerObs(time: number, errorMap: {[key: string]: any}): AsyncValidatorFn {
return (c: AbstractControl) => { return map.call(timer(time), () => errorMap); };
return (c: AbstractControl) => { return timer(time).pipe(map(() => errorMap)); };
}
const v = Validators.composeAsync(
[getTimerObs(100, {one: true}), getTimerObs(200, {two: true})]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('invalid')))
(v(new FormControl('invalid')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
tick(100);
@ -448,7 +454,6 @@ import {map} from 'rxjs/operator/map';
expect(errorMap).toEqual(
{one: true, two: true}, `Expected errors to merge once all validators resolved.`);
}));
});
});

View File

@ -16,7 +16,7 @@
"tslib": "^1.9.0"
},
"peerDependencies": {
"rxjs": "^5.5.0",
"rxjs": "^6.0.0-alpha.3",
"@angular/core": "0.0.0-PLACEHOLDER",
"@angular/platform-browser": "0.0.0-PLACEHOLDER"
},

View File

@ -13,9 +13,7 @@ const globals = {
'@angular/core': 'ng.core',
'@angular/compiler': 'ng.compiler',
'@angular/platform-browser': 'ng.platformBrowser',
'rxjs/Observable': 'Rx',
'rxjs/Observer': 'Rx',
'rxjs/Subject': 'Rx'
'rxjs': 'rxjs'
};
module.exports = {

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 {ResponseOptions} from '../base_response_options';
import {ReadyState, RequestMethod, ResponseType} from '../enums';

View File

@ -8,8 +8,7 @@
import {Injectable} from '@angular/core';
import {ɵgetDOM as getDOM} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import {Observable, Observer} from 'rxjs';
import {ResponseOptions} from '../base_response_options';
import {ContentType, ReadyState, RequestMethod, ResponseContentType, ResponseType} from '../enums';
import {Headers} from '../headers';

View File

@ -7,7 +7,7 @@
*/
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {BaseRequestOptions, RequestOptions} from './base_request_options';
import {RequestMethod} from './enums';
@ -51,7 +51,8 @@ function mergeOptions(
*
* ```typescript
* import {Http, HTTP_PROVIDERS} from '@angular/http';
* import 'rxjs/add/operator/map'
* import {map} from 'rxjs/operators';
*
* @Component({
* selector: 'http-app',
* viewProviders: [HTTP_PROVIDERS],
@ -61,7 +62,7 @@ function mergeOptions(
* constructor(http: Http) {
* http.get('people.json')
* // Call map on the response observable to get the parsed people object
* .map(res => res.json())
* .pipe(map(res => res.json()))
* // Subscribe to the observable to get the parsed people object and attach it to the
* // component
* .subscribe(people => this.people = people);

View File

@ -14,7 +14,7 @@ import {Request} from '@angular/http/src/static_request';
import {Response} from '@angular/http/src/static_response';
import {MockBackend, MockConnection} from '@angular/http/testing/src/mock_backend';
import {expect} from '@angular/platform-browser/testing/src/matchers';
import {ReplaySubject} from 'rxjs/ReplaySubject';
import {ReplaySubject} from 'rxjs';
{
describe('MockBackend', () => {

View File

@ -11,8 +11,7 @@ import {TestBed, getTestBed} from '@angular/core/testing';
import {AsyncTestCompleter, afterEach, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
import {stringToArrayBuffer} from '@angular/http/src/http_utils';
import {expect} from '@angular/platform-browser/testing/src/matchers';
import {Observable} from 'rxjs/Observable';
import {zip} from 'rxjs/observable/zip';
import {Observable, zip} from 'rxjs';
import {BaseRequestOptions, ConnectionBackend, Http, HttpModule, JSONPBackend, Jsonp, JsonpModule, Request, RequestMethod, RequestOptions, Response, ResponseContentType, ResponseOptions, URLSearchParams, XHRBackend} from '../index';
import {MockBackend, MockConnection} from '../testing/src/mock_backend';

View File

@ -14,10 +14,8 @@ const globals = {
'@angular/compiler': 'ng.compiler',
'@angular/platform-browser': 'ng.platformBrowser',
'@angular/http': 'ng.http',
'rxjs/Observable': 'Rx',
'rxjs/ReplaySubject': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs/operator/take': 'Rx.Observable.prototype'
'rxjs': 'rxjs',
'rxjs/operators': 'rxjs.operators',
};
module.exports = {

View File

@ -8,9 +8,8 @@
import {Injectable} from '@angular/core';
import {Connection, ConnectionBackend, ReadyState, Request, Response} from '@angular/http';
import {ReplaySubject} from 'rxjs/ReplaySubject';
import {Subject} from 'rxjs/Subject';
import {take} from 'rxjs/operator/take';
import {ReplaySubject, Subject} from 'rxjs';
import {take} from 'rxjs/operators';
/**
@ -40,7 +39,7 @@ export class MockConnection implements Connection {
response: ReplaySubject<Response>;
constructor(req: Request) {
this.response = <any>take.call(new ReplaySubject(1), 1);
this.response = <any>new ReplaySubject(1).pipe(take(1));
this.readyState = ReadyState.Open;
this.request = req;
}

View File

@ -35,9 +35,8 @@ function resolve(id, from) {
loc + packageName + '/fesm5/' + packageName + '.js';
return r;
}
if (id && id.startsWith('rxjs/')) {
const resolved = `${rxjsLocation}${id.replace('rxjs', '')}.js`;
return resolved;
if (id && (id == 'rxjs' || id.startsWith('rxjs/'))) {
return `${rxjsLocation}${id.replace('rxjs', '')}/index.js`;
}
if (id == 'tslib') {
return tslibLocation + '/tslib.es6.js';

View File

@ -20,13 +20,8 @@ const globals = {
'@angular/platform-browser': 'ng.platformBrowser',
'@angular/platform-browser/animations': 'ng.platformBrowser.animations',
'@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
'rxjs/Observable': 'Rx',
'rxjs/Observer': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs/Subscription': 'Rx',
'rxjs/operator/toPromise': 'Rx.Observable.prototype',
'rxjs/operator/filter': 'Rx.Observable.prototype',
'rxjs/operator/first': 'Rx.Observable.prototype'
'rxjs': 'rxjs',
'rxjs/operators': 'rxjs.operators',
};
module.exports = {

View File

@ -11,11 +11,9 @@ const xhr2: any = require('xhr2');
import {Injectable, Optional, Provider} from '@angular/core';
import {BrowserXhr, Connection, ConnectionBackend, Http, ReadyState, Request, RequestOptions, Response, XHRBackend, XSRFStrategy} from '@angular/http';
import {HttpClient, HttpEvent, HttpRequest, HttpHandler, HttpInterceptor, HttpResponse, HTTP_INTERCEPTORS, HttpBackend, XhrFactory, ɵinterceptingHandler as interceptingHandler} from '@angular/common/http';
import {HttpEvent, HttpRequest, HttpHandler, HttpInterceptor, HTTP_INTERCEPTORS, HttpBackend, XhrFactory, ɵinterceptingHandler as interceptingHandler} from '@angular/common/http';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import {Subscription} from 'rxjs/Subscription';
import {Observable, Observer, Subscription} from 'rxjs';
const isAbsoluteUrl = /^[a-zA-Z\-\+.]+:\/\//;

View File

@ -9,7 +9,7 @@
import {LocationChangeEvent, LocationChangeListener, PlatformLocation} from '@angular/common';
import {Inject, Injectable, Optional} from '@angular/core';
import {DOCUMENT, ɵgetDOM as getDOM} from '@angular/platform-browser';
import {Subject} from 'rxjs/Subject';
import {Subject} from 'rxjs';
import * as url from 'url';
import {INITIAL_CONFIG, PlatformConfig} from './tokens';

View File

@ -8,9 +8,7 @@
import {ApplicationRef, NgModuleFactory, NgModuleRef, PlatformRef, StaticProvider, Type} from '@angular/core';
import {ɵTRANSITION_ID} from '@angular/platform-browser';
import {filter} from 'rxjs/operator/filter';
import {first} from 'rxjs/operator/first';
import {toPromise} from 'rxjs/operator/toPromise';
import {first} from 'rxjs/operators';
import {PlatformState} from './platform_state';
import {platformDynamicServer, platformServer} from './server';
@ -42,8 +40,8 @@ function _render<T>(
the server-rendered app can be properly bootstrapped into a client app.`);
}
const applicationRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
return toPromise
.call(first.call(filter.call(applicationRef.isStable, (isStable: boolean) => isStable)))
return applicationRef.isStable.pipe((first((isStable: boolean) => isStable)))
.toPromise()
.then(() => {
const platformState = platform.injector.get(PlatformState);

View File

@ -17,10 +17,7 @@ import {MockBackend, MockConnection} from '@angular/http/testing';
import {BrowserModule, DOCUMENT, StateKey, Title, TransferState, makeStateKey} from '@angular/platform-browser';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformState, ServerModule, ServerTransferStateModule, platformDynamicServer, renderModule, renderModuleFactory} from '@angular/platform-server';
import {Subscription} from 'rxjs/Subscription';
import {filter} from 'rxjs/operator/filter';
import {first} from 'rxjs/operator/first';
import {toPromise} from 'rxjs/operator/toPromise';
import {first} from 'rxjs/operators';
@Component({selector: 'app', template: `Works!`})
class MyServerApp {
@ -476,15 +473,15 @@ class EscapedTransferStoreModule {
});
afterEach(() => { expect(called).toBe(true); });
it('using long from should work', async(() => {
it('using long form should work', async(() => {
const platform =
platformDynamicServer([{provide: INITIAL_CONFIG, useValue: {document: doc}}]);
platform.bootstrapModule(AsyncServerModule)
.then((moduleRef) => {
const applicationRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
return toPromise.call(first.call(
filter.call(applicationRef.isStable, (isStable: boolean) => isStable)));
return applicationRef.isStable.pipe(first((isStable: boolean) => isStable))
.toPromise();
})
.then((b) => {
expect(platform.injector.get(PlatformState).renderToString()).toBe(expectedOutput);

View File

@ -13,8 +13,7 @@ const globals = {
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/platform-browser': 'ng.platformBrowser',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx'
'rxjs': 'rxjs',
};
module.exports = {

View File

@ -36,7 +36,10 @@ System.config({
});
System.config({
map: {'rxjs': 'node_modules/rxjs', '@angular': 'dist/all/@angular'},
map: {
'@angular': 'dist/all/@angular',
'rxjs': 'node_modules/rxjs',
},
packages: {
'@angular/core/testing': {main: 'index.js', defaultExtension: 'js'},
'@angular/core': {main: 'index.js', defaultExtension: 'js'},
@ -50,7 +53,11 @@ System.config({
'@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'},
'@angular/router/testing': {main: 'index.js', defaultExtension: 'js'},
'@angular/router': {main: 'index.js', defaultExtension: 'js'},
'rxjs': {main: 'Rx.js', defaultExtension: 'js'},
'rxjs/ajax': {main: 'index.js', defaultExtension: 'js'},
'rxjs/operators': {main: 'index.js', defaultExtension: 'js'},
'rxjs/testing': {main: 'index.js', defaultExtension: 'js'},
'rxjs/websocket': {main: 'index.js', defaultExtension: 'js'},
'rxjs': {main: 'index.js', defaultExtension: 'js'},
}
});

View File

@ -35,9 +35,7 @@ module.exports = function(config) {
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',
// RxJs.
{pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false},
{pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false},
{pattern: 'node_modules/rxjs/**/*', included: false, watched: false},
// shim
{pattern: 'packages/router/karma-test-shim.js', included: true, watched: true},

View File

@ -31,7 +31,7 @@
"@angular/core": "0.0.0-PLACEHOLDER",
"@angular/common": "0.0.0-PLACEHOLDER",
"@angular/platform-browser": "0.0.0-PLACEHOLDER",
"rxjs": "^5.5.0"
"rxjs": "^6.0.0-alpha.3"
},
"ng-update": {
"packageGroup": "NG_UPDATE_PACKAGE_GROUP"

View File

@ -13,31 +13,8 @@ const globals = {
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/platform-browser': 'ng.platformBrowser',
'rxjs/BehaviorSubject': 'Rx',
'rxjs/Observable': 'Rx',
'rxjs/Observer': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs/Subscription': 'Rx',
'rxjs/util/EmptyError': 'Rx',
'rxjs/observable/from': 'Rx.Observable',
'rxjs/observable/fromPromise': 'Rx.Observable',
'rxjs/observable/forkJoin': 'Rx.Observable',
'rxjs/observable/of': 'Rx.Observable',
'rxjs/operator/toPromise': 'Rx.Observable.prototype',
'rxjs/operator/map': 'Rx.Observable.prototype',
'rxjs/operator/mergeAll': 'Rx.Observable.prototype',
'rxjs/operator/concatAll': 'Rx.Observable.prototype',
'rxjs/operator/mergeMap': 'Rx.Observable.prototype',
'rxjs/operator/reduce': 'Rx.Observable.prototype',
'rxjs/operator/every': 'Rx.Observable.prototype',
'rxjs/operator/first': 'Rx.Observable.prototype',
'rxjs/operator/catch': 'Rx.Observable.prototype',
'rxjs/operator/last': 'Rx.Observable.prototype',
'rxjs/operator/filter': 'Rx.Observable.prototype',
'rxjs/operator/concatMap': 'Rx.Observable.prototype'
'rxjs': 'rxjs',
'rxjs/operators': 'rxjs.operators',
};
module.exports = {

View File

@ -7,16 +7,8 @@
*/
import {Injector, NgModuleRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import {from} from 'rxjs/observable/from';
import {of } from 'rxjs/observable/of';
import {_catch} from 'rxjs/operator/catch';
import {concatAll} from 'rxjs/operator/concatAll';
import {first} from 'rxjs/operator/first';
import {map} from 'rxjs/operator/map';
import {mergeMap} from 'rxjs/operator/mergeMap';
import {EmptyError} from 'rxjs/util/EmptyError';
import {EmptyError, Observable, Observer, from, of } from 'rxjs';
import {catchError, concatAll, first, map, mergeMap} from 'rxjs/operators';
import {LoadedRouterConfig, Route, Routes} from './config';
import {RouterConfigLoader} from './router_config_loader';
@ -80,10 +72,10 @@ class ApplyRedirects {
apply(): Observable<UrlTree> {
const expanded$ =
this.expandSegmentGroup(this.ngModule, this.config, this.urlTree.root, PRIMARY_OUTLET);
const urlTrees$ = map.call(
expanded$, (rootSegmentGroup: UrlSegmentGroup) => this.createUrlTree(
rootSegmentGroup, this.urlTree.queryParams, this.urlTree.fragment !));
return _catch.call(urlTrees$, (e: any) => {
const urlTrees$ = expanded$.pipe(
map((rootSegmentGroup: UrlSegmentGroup) => this.createUrlTree(
rootSegmentGroup, this.urlTree.queryParams, this.urlTree.fragment !)));
return urlTrees$.pipe(catchError((e: any) => {
if (e instanceof AbsoluteRedirect) {
// after an absolute redirect we do not apply any more redirects!
this.allowRedirects = false;
@ -96,22 +88,22 @@ class ApplyRedirects {
}
throw e;
});
}));
}
private match(tree: UrlTree): Observable<UrlTree> {
const expanded$ =
this.expandSegmentGroup(this.ngModule, this.config, tree.root, PRIMARY_OUTLET);
const mapped$ = map.call(
expanded$, (rootSegmentGroup: UrlSegmentGroup) =>
this.createUrlTree(rootSegmentGroup, tree.queryParams, tree.fragment !));
return _catch.call(mapped$, (e: any): Observable<UrlTree> => {
const mapped$ = expanded$.pipe(
map((rootSegmentGroup: UrlSegmentGroup) =>
this.createUrlTree(rootSegmentGroup, tree.queryParams, tree.fragment !)));
return mapped$.pipe(catchError((e: any): Observable<UrlTree> => {
if (e instanceof NoMatch) {
throw this.noMatchError(e);
}
throw e;
});
}));
}
private noMatchError(e: NoMatch): any {
@ -130,9 +122,8 @@ class ApplyRedirects {
ngModule: NgModuleRef<any>, routes: Route[], segmentGroup: UrlSegmentGroup,
outlet: string): Observable<UrlSegmentGroup> {
if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
return map.call(
this.expandChildren(ngModule, routes, segmentGroup),
(children: any) => new UrlSegmentGroup([], children));
return this.expandChildren(ngModule, routes, segmentGroup)
.pipe(map((children: any) => new UrlSegmentGroup([], children)));
}
return this.expandSegment(ngModule, segmentGroup, routes, segmentGroup.segments, outlet, true);
@ -151,31 +142,28 @@ class ApplyRedirects {
ngModule: NgModuleRef<any>, segmentGroup: UrlSegmentGroup, routes: Route[],
segments: UrlSegment[], outlet: string,
allowRedirects: boolean): Observable<UrlSegmentGroup> {
const routes$ = of (...routes);
const processedRoutes$ = map.call(routes$, (r: any) => {
const expanded$ = this.expandSegmentAgainstRoute(
ngModule, segmentGroup, routes, r, segments, outlet, allowRedirects);
return _catch.call(expanded$, (e: any) => {
if (e instanceof NoMatch) {
return of (null);
}
throw e;
});
});
const concattedProcessedRoutes$ = concatAll.call(processedRoutes$);
const first$ = first.call(concattedProcessedRoutes$, (s: any) => !!s);
return _catch.call(first$, (e: any, _: any): Observable<UrlSegmentGroup> => {
if (e instanceof EmptyError || e.name === 'EmptyError') {
if (this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
return of (new UrlSegmentGroup([], {}));
}
throw new NoMatch(segmentGroup);
}
throw e;
});
return of (...routes).pipe(
map((r: any) => {
const expanded$ = this.expandSegmentAgainstRoute(
ngModule, segmentGroup, routes, r, segments, outlet, allowRedirects);
return expanded$.pipe(catchError((e: any) => {
if (e instanceof NoMatch) {
// TODO(i): this return type doesn't match the declared Observable<UrlSegmentGroup> -
// talk to Jason
return of (null) as any;
}
throw e;
}));
}),
concatAll(), first((s: any) => !!s), catchError((e: any, _: any) => {
if (e instanceof EmptyError || e.name === 'EmptyError') {
if (this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
return of (new UrlSegmentGroup([], {}));
}
throw new NoMatch(segmentGroup);
}
throw e;
}));
}
private noLeftoversInUrl(segmentGroup: UrlSegmentGroup, segments: UrlSegment[], outlet: string):
@ -222,10 +210,10 @@ class ApplyRedirects {
return absoluteRedirect(newTree);
}
return mergeMap.call(this.lineralizeSegments(route, newTree), (newSegments: UrlSegment[]) => {
return this.lineralizeSegments(route, newTree).pipe(mergeMap((newSegments: UrlSegment[]) => {
const group = new UrlSegmentGroup(newSegments, {});
return this.expandSegment(ngModule, group, routes, newSegments, outlet, false);
});
}));
}
private expandRegularSegmentAgainstRouteUsingRedirect(
@ -241,11 +229,11 @@ class ApplyRedirects {
return absoluteRedirect(newTree);
}
return mergeMap.call(this.lineralizeSegments(route, newTree), (newSegments: UrlSegment[]) => {
return this.lineralizeSegments(route, newTree).pipe(mergeMap((newSegments: UrlSegment[]) => {
return this.expandSegment(
ngModule, segmentGroup, routes, newSegments.concat(segments.slice(lastChild)), outlet,
false);
});
}));
}
private matchSegmentAgainstRoute(
@ -253,11 +241,11 @@ class ApplyRedirects {
segments: UrlSegment[]): Observable<UrlSegmentGroup> {
if (route.path === '**') {
if (route.loadChildren) {
return map.call(
this.configLoader.load(ngModule.injector, route), (cfg: LoadedRouterConfig) => {
return this.configLoader.load(ngModule.injector, route)
.pipe(map((cfg: LoadedRouterConfig) => {
route._loadedConfig = cfg;
return new UrlSegmentGroup(segments, {});
});
}));
}
return of (new UrlSegmentGroup(segments, {}));
@ -269,7 +257,7 @@ class ApplyRedirects {
const rawSlicedSegments = segments.slice(lastChild);
const childConfig$ = this.getChildConfig(ngModule, route);
return mergeMap.call(childConfig$, (routerConfig: LoadedRouterConfig) => {
return childConfig$.pipe(mergeMap((routerConfig: LoadedRouterConfig) => {
const childModule = routerConfig.module;
const childConfig = routerConfig.routes;
@ -278,8 +266,8 @@ class ApplyRedirects {
if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
const expanded$ = this.expandChildren(childModule, childConfig, segmentGroup);
return map.call(
expanded$, (children: any) => new UrlSegmentGroup(consumedSegments, children));
return expanded$.pipe(
map((children: any) => new UrlSegmentGroup(consumedSegments, children)));
}
if (childConfig.length === 0 && slicedSegments.length === 0) {
@ -288,10 +276,10 @@ class ApplyRedirects {
const expanded$ = this.expandSegment(
childModule, segmentGroup, childConfig, slicedSegments, PRIMARY_OUTLET, true);
return map.call(
expanded$, (cs: UrlSegmentGroup) =>
new UrlSegmentGroup(consumedSegments.concat(cs.segments), cs.children));
});
return expanded$.pipe(
map((cs: UrlSegmentGroup) =>
new UrlSegmentGroup(consumedSegments.concat(cs.segments), cs.children)));
}));
}
private getChildConfig(ngModule: NgModuleRef<any>, route: Route): Observable<LoadedRouterConfig> {
@ -306,18 +294,16 @@ class ApplyRedirects {
return of (route._loadedConfig);
}
return mergeMap.call(runCanLoadGuard(ngModule.injector, route), (shouldLoad: boolean) => {
return runCanLoadGuard(ngModule.injector, route).pipe(mergeMap((shouldLoad: boolean) => {
if (shouldLoad) {
return map.call(
this.configLoader.load(ngModule.injector, route), (cfg: LoadedRouterConfig) => {
return this.configLoader.load(ngModule.injector, route)
.pipe(map((cfg: LoadedRouterConfig) => {
route._loadedConfig = cfg;
return cfg;
});
}));
}
return canLoadFails(route);
});
}));
}
return of (new LoadedRouterConfig([], ngModule));
@ -417,10 +403,10 @@ function runCanLoadGuard(moduleInjector: Injector, route: Route): Observable<boo
const canLoad = route.canLoad;
if (!canLoad || canLoad.length === 0) return of (true);
const obs = map.call(from(canLoad), (injectionToken: any) => {
const obs = from(canLoad).pipe(map((injectionToken: any) => {
const guard = moduleInjector.get(injectionToken);
return wrapIntoObservable(guard.canLoad ? guard.canLoad(route) : guard(route));
});
}));
return andObservables(obs);
}

View File

@ -7,7 +7,7 @@
*/
import {NgModuleFactory, NgModuleRef, Type} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {PRIMARY_OUTLET} from './shared';
import {UrlSegment, UrlSegmentGroup} from './url_tree';
@ -462,4 +462,4 @@ function getFullPath(parentPath: string, currentRoute: Route): string {
export function copyConfig(r: Route): Route {
const children = r.children && r.children.map(copyConfig);
return children ? {...r, children} : {...r};
}
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {BehaviorSubject} from 'rxjs';
import {DetachedRouteHandleInternal, RouteReuseStrategy} from './route_reuse_strategy';
import {ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot} from './router_state';
@ -74,4 +74,4 @@ function createActivatedRoute(c: ActivatedRouteSnapshot) {
return new ActivatedRoute(
new BehaviorSubject(c.url), new BehaviorSubject(c.params), new BehaviorSubject(c.queryParams),
new BehaviorSubject(c.fragment), new BehaviorSubject(c.data), c.outlet, c.component, c);
}
}

View File

@ -8,14 +8,15 @@
import {LocationStrategy} from '@angular/common';
import {Attribute, Directive, ElementRef, HostBinding, HostListener, Input, OnChanges, OnDestroy, Renderer2, isDevMode} from '@angular/core';
import {Subscription} from 'rxjs/Subscription';
import {Subscription} from 'rxjs';
import {QueryParamsHandling} from '../config';
import {NavigationEnd} from '../events';
import {NavigationEnd, RouterEvent} from '../events';
import {Router} from '../router';
import {ActivatedRoute} from '../router_state';
import {UrlTree} from '../url_tree';
/**
* @whatItDoes Lets you link to specific parts of your app.
*
@ -184,7 +185,7 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy {
constructor(
private router: Router, private route: ActivatedRoute,
private locationStrategy: LocationStrategy) {
this.subscription = router.events.subscribe(s => {
this.subscription = router.events.subscribe((s: RouterEvent) => {
if (s instanceof NavigationEnd) {
this.updateTargetUrlAndHref();
}

View File

@ -7,11 +7,14 @@
*/
import {AfterContentInit, ChangeDetectorRef, ContentChildren, Directive, ElementRef, Input, OnChanges, OnDestroy, QueryList, Renderer2, SimpleChanges} from '@angular/core';
import {Subscription} from 'rxjs/Subscription';
import {NavigationEnd} from '../events';
import {Subscription} from 'rxjs';
import {NavigationEnd, RouterEvent} from '../events';
import {Router} from '../router';
import {RouterLink, RouterLinkWithHref} from './router_link';
/**
* @whatItDoes Lets you add a CSS class to an element when the link's route becomes active.
*
@ -93,7 +96,7 @@ export class RouterLinkActive implements OnChanges,
constructor(
private router: Router, private element: ElementRef, private renderer: Renderer2,
private cdr: ChangeDetectorRef) {
this.subscription = router.events.subscribe(s => {
this.subscription = router.events.subscribe((s: RouterEvent) => {
if (s instanceof NavigationEnd) {
this.update();
}

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 {Route} from './config';
import {ActivatedRouteSnapshot, RouterStateSnapshot} from './router_state';

View File

@ -7,16 +7,8 @@
*/
import {Injector} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {from} from 'rxjs/observable/from';
import {of } from 'rxjs/observable/of';
import {concatMap} from 'rxjs/operator/concatMap';
import {every} from 'rxjs/operator/every';
import {first} from 'rxjs/operator/first';
import {last} from 'rxjs/operator/last';
import {map} from 'rxjs/operator/map';
import {mergeMap} from 'rxjs/operator/mergeMap';
import {reduce} from 'rxjs/operator/reduce';
import {Observable, from, of } from 'rxjs';
import {concatMap, every, first, last, map, mergeMap, reduce} from 'rxjs/operators';
import {LoadedRouterConfig, ResolveData, RunGuardsAndResolvers} from './config';
import {ActivationStart, ChildActivationStart, Event} from './events';
@ -58,17 +50,17 @@ export class PreActivation {
return of (true);
}
const canDeactivate$ = this.runCanDeactivateChecks();
return mergeMap.call(
canDeactivate$,
(canDeactivate: boolean) => canDeactivate ? this.runCanActivateChecks() : of (false));
return canDeactivate$.pipe(mergeMap(
(canDeactivate: boolean) => canDeactivate ? this.runCanActivateChecks() : of (false)));
}
resolveData(paramsInheritanceStrategy: 'emptyOnly'|'always'): Observable<any> {
if (!this.isActivating()) return of (null);
const checks$ = from(this.canActivateChecks);
const runningChecks$ = concatMap.call(
checks$, (check: CanActivate) => this.runResolve(check.route, paramsInheritanceStrategy));
return reduce.call(runningChecks$, (_: any, __: any) => _);
return from(this.canActivateChecks)
.pipe(
concatMap(
(check: CanActivate) => this.runResolve(check.route, paramsInheritanceStrategy)),
reduce((_: any, __: any) => _));
}
isDeactivating(): boolean { return this.canDeactivateChecks.length !== 0; }
@ -194,21 +186,21 @@ export class PreActivation {
}
private runCanDeactivateChecks(): Observable<boolean> {
const checks$ = from(this.canDeactivateChecks);
const runningChecks$ = mergeMap.call(
checks$, (check: CanDeactivate) => this.runCanDeactivate(check.component, check.route));
return every.call(runningChecks$, (result: boolean) => result === true);
return from(this.canDeactivateChecks)
.pipe(
mergeMap((check: CanDeactivate) => this.runCanDeactivate(check.component, check.route)),
every((result: boolean) => result === true));
}
private runCanActivateChecks(): Observable<boolean> {
const checks$ = from(this.canActivateChecks);
const runningChecks$ = concatMap.call(
checks$,
(check: CanActivate) => andObservables(from([
this.fireChildActivationStart(check.route.parent), this.fireActivationStart(check.route),
this.runCanActivateChild(check.path), this.runCanActivate(check.route)
])));
return every.call(runningChecks$, (result: boolean) => result === true);
return from(this.canActivateChecks)
.pipe(
concatMap((check: CanActivate) => andObservables(from([
this.fireChildActivationStart(check.route.parent),
this.fireActivationStart(check.route), this.runCanActivateChild(check.path),
this.runCanActivate(check.route)
]))),
every((result: boolean) => result === true));
// this.fireChildActivationStart(check.path),
}
@ -245,7 +237,7 @@ export class PreActivation {
private runCanActivate(future: ActivatedRouteSnapshot): Observable<boolean> {
const canActivate = future.routeConfig ? future.routeConfig.canActivate : null;
if (!canActivate || canActivate.length === 0) return of (true);
const obs = map.call(from(canActivate), (c: any) => {
const obs = from(canActivate).pipe(map((c: any) => {
const guard = this.getToken(c, future);
let observable: Observable<boolean>;
if (guard.canActivate) {
@ -253,8 +245,8 @@ export class PreActivation {
} else {
observable = wrapIntoObservable(guard(future, this.future));
}
return first.call(observable);
});
return observable.pipe(first());
}));
return andObservables(obs);
}
@ -266,8 +258,8 @@ export class PreActivation {
.map(p => this.extractCanActivateChild(p))
.filter(_ => _ !== null);
return andObservables(map.call(from(canActivateChildGuards), (d: any) => {
const obs = map.call(from(d.guards), (c: any) => {
return andObservables(from(canActivateChildGuards).pipe(map((d: any) => {
const obs = from(d.guards).pipe(map((c: any) => {
const guard = this.getToken(c, d.node);
let observable: Observable<boolean>;
if (guard.canActivateChild) {
@ -275,10 +267,10 @@ export class PreActivation {
} else {
observable = wrapIntoObservable(guard(future, this.future));
}
return first.call(observable);
});
return observable.pipe(first());
}));
return andObservables(obs);
}));
})));
}
private extractCanActivateChild(p: ActivatedRouteSnapshot):
@ -292,7 +284,7 @@ export class PreActivation {
Observable<boolean> {
const canDeactivate = curr && curr.routeConfig ? curr.routeConfig.canDeactivate : null;
if (!canDeactivate || canDeactivate.length === 0) return of (true);
const canDeactivate$ = mergeMap.call(from(canDeactivate), (c: any) => {
const canDeactivate$ = from(canDeactivate).pipe(mergeMap((c: any) => {
const guard = this.getToken(c, curr);
let observable: Observable<boolean>;
if (guard.canDeactivate) {
@ -301,21 +293,21 @@ export class PreActivation {
} else {
observable = wrapIntoObservable(guard(component, curr, this.curr, this.future));
}
return first.call(observable);
});
return every.call(canDeactivate$, (result: any) => result === true);
return observable.pipe(first());
}));
return canDeactivate$.pipe(every((result: any) => result === true));
}
private runResolve(
future: ActivatedRouteSnapshot,
paramsInheritanceStrategy: 'emptyOnly'|'always'): Observable<any> {
const resolve = future._resolve;
return map.call(this.resolveNode(resolve, future), (resolvedData: any): any => {
return this.resolveNode(resolve, future).pipe(map((resolvedData: any): any => {
future._resolvedData = resolvedData;
future.data = {...future.data,
...inheritedParamsDataResolve(future, paramsInheritanceStrategy).resolve};
return null;
});
}));
}
private resolveNode(resolve: ResolveData, future: ActivatedRouteSnapshot): Observable<any> {
@ -325,17 +317,18 @@ export class PreActivation {
}
if (keys.length === 1) {
const key = keys[0];
return map.call(
this.getResolver(resolve[key], future), (value: any) => { return {[key]: value}; });
return this.getResolver(resolve[key], future).pipe(map((value: any) => {
return {[key]: value};
}));
}
const data: {[k: string]: any} = {};
const runningResolvers$ = mergeMap.call(from(keys), (key: string) => {
return map.call(this.getResolver(resolve[key], future), (value: any) => {
const runningResolvers$ = from(keys).pipe(mergeMap((key: string) => {
return this.getResolver(resolve[key], future).pipe(map((value: any) => {
data[key] = value;
return value;
});
});
return map.call(last.call(runningResolvers$), () => data);
}));
}));
return runningResolvers$.pipe(last(), map(() => data));
}
private getResolver(injectionToken: any, future: ActivatedRouteSnapshot): Observable<any> {

View File

@ -7,9 +7,7 @@
*/
import {Type} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import {of } from 'rxjs/observable/of';
import {Observable, Observer, of } from 'rxjs';
import {Data, ResolveData, Route, Routes} from './config';
import {ActivatedRouteSnapshot, ParamsInheritanceStrategy, RouterStateSnapshot, inheritedParamsDataResolve} from './router_state';

View File

@ -8,14 +8,8 @@
import {Location} from '@angular/common';
import {Compiler, Injector, NgModuleFactoryLoader, NgModuleRef, Type, isDevMode} from '@angular/core';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {Subscription} from 'rxjs/Subscription';
import {of } from 'rxjs/observable/of';
import {concatMap} from 'rxjs/operator/concatMap';
import {map} from 'rxjs/operator/map';
import {mergeMap} from 'rxjs/operator/mergeMap';
import {BehaviorSubject, Observable, Subject, Subscription, of } from 'rxjs';
import {concatMap, map, mergeMap} from 'rxjs/operators';
import {applyRedirects} from './apply_redirects';
import {LoadedRouterConfig, QueryParamsHandling, Route, Routes, copyConfig, validateConfig} from './config';
@ -163,6 +157,9 @@ function defaultErrorHandler(error: any): any {
throw error;
}
type NavStreamValue =
boolean | {appliedUrl: UrlTree, snapshot: RouterStateSnapshot, shouldActivate?: boolean};
type NavigationParams = {
id: number,
rawUrl: UrlTree,
@ -511,19 +508,17 @@ export class Router {
}
private processNavigations(): void {
concatMap
.call(
this.navigations,
(nav: NavigationParams) => {
if (nav) {
this.executeScheduledNavigation(nav);
// a failed navigation should not stop the router from processing
// further navigations => the catch
return nav.promise.catch(() => {});
} else {
return <any>of (null);
}
})
this.navigations
.pipe(concatMap((nav: NavigationParams) => {
if (nav) {
this.executeScheduledNavigation(nav);
// a failed navigation should not stop the router from processing
// further navigations => the catch
return nav.promise.catch(() => {});
} else {
return <any>of (null);
}
}))
.subscribe(() => {});
}
@ -620,98 +615,101 @@ export class Router {
return new Promise((resolvePromise, rejectPromise) => {
// create an observable of the url and route state snapshot
// this operation do not result in any side effects
let urlAndSnapshot$: Observable<{appliedUrl: UrlTree, snapshot: RouterStateSnapshot}>;
let urlAndSnapshot$: Observable<NavStreamValue>;
if (!precreatedState) {
const moduleInjector = this.ngModule.injector;
const redirectsApplied$ =
applyRedirects(moduleInjector, this.configLoader, this.urlSerializer, url, this.config);
urlAndSnapshot$ = mergeMap.call(redirectsApplied$, (appliedUrl: UrlTree) => {
return map.call(
recognize(
this.rootComponentType, this.config, appliedUrl, this.serializeUrl(appliedUrl),
this.paramsInheritanceStrategy),
(snapshot: any) => {
urlAndSnapshot$ = redirectsApplied$.pipe(mergeMap((appliedUrl: UrlTree) => {
return recognize(
this.rootComponentType, this.config, appliedUrl, this.serializeUrl(appliedUrl),
this.paramsInheritanceStrategy)
.pipe(map((snapshot: any) => {
(this.events as Subject<Event>)
.next(new RoutesRecognized(
id, this.serializeUrl(url), this.serializeUrl(appliedUrl), snapshot));
return {appliedUrl, snapshot};
});
});
}));
}));
} else {
urlAndSnapshot$ = of ({appliedUrl: url, snapshot: precreatedState});
}
const beforePreactivationDone$ = mergeMap.call(
urlAndSnapshot$, (p: {appliedUrl: string, snapshot: RouterStateSnapshot}) => {
return map.call(this.hooks.beforePreactivation(p.snapshot), () => p);
});
const beforePreactivationDone$ =
urlAndSnapshot$.pipe(mergeMap((p): Observable<NavStreamValue> => {
if (typeof p === 'boolean') return of (p);
return this.hooks.beforePreactivation(p.snapshot).pipe(map(() => p));
}));
// run preactivation: guards and data resolvers
let preActivation: PreActivation;
const preactivationSetup$ = map.call(
beforePreactivationDone$,
({appliedUrl, snapshot}: {appliedUrl: string, snapshot: RouterStateSnapshot}) => {
const moduleInjector = this.ngModule.injector;
preActivation = new PreActivation(
snapshot, this.routerState.snapshot, moduleInjector,
(evt: Event) => this.triggerEvent(evt));
preActivation.initialize(this.rootContexts);
return {appliedUrl, snapshot};
});
const preactivationSetup$ = beforePreactivationDone$.pipe(map((p): NavStreamValue => {
if (typeof p === 'boolean') return p;
const {appliedUrl, snapshot} = p;
const moduleInjector = this.ngModule.injector;
preActivation = new PreActivation(
snapshot, this.routerState.snapshot, moduleInjector,
(evt: Event) => this.triggerEvent(evt));
preActivation.initialize(this.rootContexts);
return {appliedUrl, snapshot};
}));
const preactivationCheckGuards$ = mergeMap.call(
preactivationSetup$,
({appliedUrl, snapshot}: {appliedUrl: string, snapshot: RouterStateSnapshot}) => {
if (this.navigationId !== id) return of (false);
const preactivationCheckGuards$ =
preactivationSetup$.pipe(mergeMap((p): Observable<NavStreamValue> => {
if (typeof p === 'boolean' || this.navigationId !== id) return of (false);
const {appliedUrl, snapshot} = p;
this.triggerEvent(
new GuardsCheckStart(id, this.serializeUrl(url), appliedUrl, snapshot));
this.triggerEvent(new GuardsCheckStart(
id, this.serializeUrl(url), this.serializeUrl(appliedUrl), snapshot));
return map.call(preActivation.checkGuards(), (shouldActivate: boolean) => {
return preActivation.checkGuards().pipe(map((shouldActivate: boolean) => {
this.triggerEvent(new GuardsCheckEnd(
id, this.serializeUrl(url), appliedUrl, snapshot, shouldActivate));
id, this.serializeUrl(url), this.serializeUrl(appliedUrl), snapshot,
shouldActivate));
return {appliedUrl: appliedUrl, snapshot: snapshot, shouldActivate: shouldActivate};
});
});
}));
}));
const preactivationResolveData$ = mergeMap.call(
preactivationCheckGuards$,
(p: {appliedUrl: string, snapshot: RouterStateSnapshot, shouldActivate: boolean}) => {
if (this.navigationId !== id) return of (false);
const preactivationResolveData$ =
preactivationCheckGuards$.pipe(mergeMap((p): Observable<NavStreamValue> => {
if (typeof p === 'boolean' || this.navigationId !== id) return of (false);
if (p.shouldActivate && preActivation.isActivating()) {
this.triggerEvent(
new ResolveStart(id, this.serializeUrl(url), p.appliedUrl, p.snapshot));
return map.call(preActivation.resolveData(this.paramsInheritanceStrategy), () => {
this.triggerEvent(
new ResolveEnd(id, this.serializeUrl(url), p.appliedUrl, p.snapshot));
this.triggerEvent(new ResolveStart(
id, this.serializeUrl(url), this.serializeUrl(p.appliedUrl), p.snapshot));
return preActivation.resolveData(this.paramsInheritanceStrategy).pipe(map(() => {
this.triggerEvent(new ResolveEnd(
id, this.serializeUrl(url), this.serializeUrl(p.appliedUrl), p.snapshot));
return p;
});
}));
} else {
return of (p);
}
});
}));
const preactivationDone$ = mergeMap.call(preactivationResolveData$, (p: any) => {
return map.call(this.hooks.afterPreactivation(p.snapshot), () => p);
});
const preactivationDone$ =
preactivationResolveData$.pipe(mergeMap((p): Observable<NavStreamValue> => {
if (typeof p === 'boolean' || this.navigationId !== id) return of (false);
return this.hooks.afterPreactivation(p.snapshot).pipe(map(() => p));
}));
// create router state
// this operation has side effects => route state is being affected
const routerState$ =
map.call(preactivationDone$, ({appliedUrl, snapshot, shouldActivate}: any) => {
if (shouldActivate) {
const state = createRouterState(this.routeReuseStrategy, snapshot, this.routerState);
return {appliedUrl, state, shouldActivate};
} else {
return {appliedUrl, state: null, shouldActivate};
}
});
const routerState$ = preactivationDone$.pipe(map((p) => {
if (typeof p === 'boolean' || this.navigationId !== id) return false;
const {appliedUrl, snapshot, shouldActivate} = p;
if (shouldActivate) {
const state = createRouterState(this.routeReuseStrategy, snapshot, this.routerState);
return {appliedUrl, state, shouldActivate};
} else {
return {appliedUrl, state: null, shouldActivate};
}
}));
this.activateRoutes(
routerState$, this.routerState, this.currentUrlTree, id, url, rawUrl, skipLocationChange,
@ -724,7 +722,8 @@ export class Router {
* is a private method, it could be overridden to make activation asynchronous.
*/
private activateRoutes(
state: Observable<{appliedUrl: string, state: RouterState, shouldActivate: boolean}>,
state: Observable<false|
{appliedUrl: UrlTree, state: RouterState|null, shouldActivate?: boolean}>,
storedState: RouterState, storedUrl: UrlTree, id: number, url: UrlTree, rawUrl: UrlTree,
skipLocationChange: boolean, replaceUrl: boolean, resolvePromise: any, rejectPromise: any) {
// applied the new router state
@ -732,12 +731,12 @@ export class Router {
let navigationIsSuccessful: boolean;
state
.forEach(({appliedUrl, state, shouldActivate}: any) => {
if (!shouldActivate || id !== this.navigationId) {
.forEach((p) => {
if (typeof p === 'boolean' || !p.shouldActivate || id !== this.navigationId || !p.state) {
navigationIsSuccessful = false;
return;
}
const {appliedUrl, state} = p;
this.currentUrlTree = appliedUrl;
this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, rawUrl);

View File

@ -6,12 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Compiler, InjectionToken, Injector, NgModuleFactory, NgModuleFactoryLoader, NgModuleRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {fromPromise} from 'rxjs/observable/fromPromise';
import {of } from 'rxjs/observable/of';
import {map} from 'rxjs/operator/map';
import {mergeMap} from 'rxjs/operator/mergeMap';
import {Compiler, InjectionToken, Injector, NgModuleFactory, NgModuleFactoryLoader} from '@angular/core';
// TODO(i): switch to fromPromise once it's expored in rxjs
import {Observable, from, of } from 'rxjs';
import {map, mergeMap} from 'rxjs/operators';
import {LoadChildren, LoadedRouterConfig, Route, copyConfig} from './config';
import {flatten, wrapIntoObservable} from './utils/collection';
@ -34,7 +32,7 @@ export class RouterConfigLoader {
const moduleFactory$ = this.loadModuleFactory(route.loadChildren !);
return map.call(moduleFactory$, (factory: NgModuleFactory<any>) => {
return moduleFactory$.pipe(map((factory: NgModuleFactory<any>) => {
if (this.onLoadEndListener) {
this.onLoadEndListener(route);
}
@ -42,20 +40,20 @@ export class RouterConfigLoader {
const module = factory.create(parentInjector);
return new LoadedRouterConfig(flatten(module.injector.get(ROUTES)).map(copyConfig), module);
});
}));
}
private loadModuleFactory(loadChildren: LoadChildren): Observable<NgModuleFactory<any>> {
if (typeof loadChildren === 'string') {
return fromPromise(this.loader.load(loadChildren));
return from(this.loader.load(loadChildren));
} else {
return mergeMap.call(wrapIntoObservable(loadChildren()), (t: any) => {
return wrapIntoObservable(loadChildren()).pipe(mergeMap((t: any) => {
if (t instanceof NgModuleFactory) {
return of (t);
} else {
return fromPromise(this.compiler.compileModuleAsync(t));
return from(this.compiler.compileModuleAsync(t));
}
});
}));
}
}
}

View File

@ -9,13 +9,13 @@
import {APP_BASE_HREF, HashLocationStrategy, LOCATION_INITIALIZED, Location, LocationStrategy, PathLocationStrategy, PlatformLocation} from '@angular/common';
import {ANALYZE_FOR_ENTRY_COMPONENTS, APP_BOOTSTRAP_LISTENER, APP_INITIALIZER, ApplicationRef, Compiler, ComponentRef, Inject, Injectable, InjectionToken, Injector, ModuleWithProviders, NgModule, NgModuleFactoryLoader, NgProbeToken, Optional, Provider, SkipSelf, SystemJsNgModuleLoader} from '@angular/core';
import {ɵgetDOM as getDOM} from '@angular/platform-browser';
import {Subject} from 'rxjs/Subject';
import {of } from 'rxjs/observable/of';
import {Subject, of } from 'rxjs';
import {Route, Routes} from './config';
import {RouterLink, RouterLinkWithHref} from './directives/router_link';
import {RouterLinkActive} from './directives/router_link_active';
import {RouterOutlet} from './directives/router_outlet';
import {RouterEvent} from './events';
import {RouteReuseStrategy} from './route_reuse_strategy';
import {ErrorHandler, Router} from './router';
import {ROUTES} from './router_config_loader';
@ -27,6 +27,7 @@ import {DefaultUrlSerializer, UrlSerializer} from './url_tree';
import {flatten} from './utils/collection';
/**
* @whatItDoes Contains a list of directives
* @stable
@ -312,7 +313,7 @@ export function setupRouter(
if (opts.enableTracing) {
const dom = getDOM();
router.events.subscribe(e => {
router.events.subscribe((e: RouterEvent) => {
dom.logGroup(`Router Event: ${(<any>e.constructor).name}`);
dom.log(e.toString());
dom.log(e);

View File

@ -7,20 +7,15 @@
*/
import {Compiler, Injectable, Injector, NgModuleFactoryLoader, NgModuleRef, OnDestroy} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Subscription} from 'rxjs/Subscription';
import {from} from 'rxjs/observable/from';
import {of } from 'rxjs/observable/of';
import {_catch} from 'rxjs/operator/catch';
import {concatMap} from 'rxjs/operator/concatMap';
import {filter} from 'rxjs/operator/filter';
import {mergeAll} from 'rxjs/operator/mergeAll';
import {mergeMap} from 'rxjs/operator/mergeMap';
import {Observable, Subscription, from, of } from 'rxjs';
import {catchError, concatMap, filter, map, mergeAll, mergeMap} from 'rxjs/operators';
import {LoadedRouterConfig, Route, Routes} from './config';
import {Event, NavigationEnd, RouteConfigLoadEnd, RouteConfigLoadStart} from './events';
import {Router} from './router';
import {RouterConfigLoader} from './router_config_loader';
/**
* @whatItDoes Provides a preloading strategy.
*
@ -43,7 +38,7 @@ export abstract class PreloadingStrategy {
*/
export class PreloadAllModules implements PreloadingStrategy {
preload(route: Route, fn: () => Observable<any>): Observable<any> {
return _catch.call(fn(), () => of (null));
return fn().pipe(catchError(() => of (null)));
}
}
@ -87,8 +82,10 @@ export class RouterPreloader implements OnDestroy {
}
setUpPreloading(): void {
const navigations$ = filter.call(this.router.events, (e: Event) => e instanceof NavigationEnd);
this.subscription = concatMap.call(navigations$, () => this.preload()).subscribe(() => {});
this.subscription =
this.router.events
.pipe(filter((e: Event) => e instanceof NavigationEnd), concatMap(() => this.preload()))
.subscribe(() => {});
}
preload(): Observable<any> {
@ -118,16 +115,16 @@ export class RouterPreloader implements OnDestroy {
res.push(this.processRoutes(ngModule, route.children));
}
}
return mergeAll.call(from(res));
return from(res).pipe(mergeAll(), map((_) => void 0));
}
private preloadConfig(ngModule: NgModuleRef<any>, route: Route): Observable<void> {
return this.preloadingStrategy.preload(route, () => {
const loaded$ = this.loader.load(ngModule.injector, route);
return mergeMap.call(loaded$, (config: LoadedRouterConfig) => {
return loaded$.pipe(mergeMap((config: LoadedRouterConfig) => {
route._loadedConfig = config;
return this.processRoutes(config.module, config.routes);
});
}));
});
}
}

View File

@ -7,9 +7,8 @@
*/
import {Type} from '@angular/core';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {Observable} from 'rxjs/Observable';
import {map} from 'rxjs/operator/map';
import {BehaviorSubject, Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {Data, ResolveData, Route} from './config';
import {PRIMARY_OUTLET, ParamMap, Params, convertToParamMap} from './shared';
@ -157,7 +156,7 @@ export class ActivatedRoute {
get paramMap(): Observable<ParamMap> {
if (!this._paramMap) {
this._paramMap = map.call(this.params, (p: Params): ParamMap => convertToParamMap(p));
this._paramMap = this.params.pipe(map((p: Params): ParamMap => convertToParamMap(p)));
}
return this._paramMap;
}
@ -165,7 +164,7 @@ export class ActivatedRoute {
get queryParamMap(): Observable<ParamMap> {
if (!this._queryParamMap) {
this._queryParamMap =
map.call(this.queryParams, (p: Params): ParamMap => convertToParamMap(p));
this.queryParams.pipe(map((p: Params): ParamMap => convertToParamMap(p)));
}
return this._queryParamMap;
}

View File

@ -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);

View File

@ -8,8 +8,7 @@
import {NgModuleRef} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {Observable} from 'rxjs/Observable';
import {of } from 'rxjs/observable/of';
import {Observable, of } from 'rxjs';
import {applyRedirects} from '../src/apply_redirects';
import {LoadedRouterConfig, Routes} from '../src/config';

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {BehaviorSubject} from 'rxjs';
import {createUrlTree} from '../src/create_url_tree';
import {ActivatedRoute, ActivatedRouteSnapshot, advanceActivatedRoute} from '../src/router_state';
@ -267,4 +267,4 @@ function create(
new BehaviorSubject(null !), new BehaviorSubject(null !), PRIMARY_OUTLET, 'someComponent', s);
advanceActivatedRoute(a);
return createUrlTree(a, tree, commands, queryParams !, fragment !);
}
}

Some files were not shown because too many files have changed in this diff Show More