refactor: core, http & platform-webworker to remove public private class separation (#19143)

The private classes `ApplicationRef_`, `PlatformRef_`, `JSONPConnection_`, `JSONPBackend_`, `ClientMessageBrokerFactory_`, `ServiceMessageBroker_`, `ClientMessageBroker_` and `ServiceMessageBrokerFactory_` have been removed and merged into their public equivalents.

The size of the minified umd bundles have been slightly decreased:
| package            | before     | after      |
| -------------------|------------|------------|
| core               | 217.791 kb | 217.144 kb |
| http               | 33.260 kb  | 32.838 kb  | 
| platform-webworker | 56.015 kb  | 54.933 kb  |
PR Close #19143
This commit is contained in:
Olivier Combe
2017-09-12 20:45:02 +02:00
committed by Matias Niemelä
parent 0c44e733ad
commit b6431c60e6
19 changed files with 252 additions and 326 deletions

View File

@ -22,11 +22,16 @@ const JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
const JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';
/**
* Abstract base class for an in-flight JSONP request.
* Base class for an in-flight JSONP request.
*
* @deprecated use @angular/common/http instead
*/
export abstract class JSONPConnection implements Connection {
export class JSONPConnection implements Connection {
private _id: string;
private _script: Element;
private _responseData: any;
private _finished: boolean = false;
/**
* The {@link ReadyState} of this request.
*/
@ -42,22 +47,9 @@ export abstract class JSONPConnection implements Connection {
*/
response: Observable<Response>;
/**
* Callback called when the JSONP request completes, to notify the application
* of the new data.
*/
abstract finished(data?: any): void;
}
export class JSONPConnection_ extends JSONPConnection {
private _id: string;
private _script: Element;
private _responseData: any;
private _finished: boolean = false;
/** @internal */
constructor(
req: Request, private _dom: BrowserJsonp, private baseResponseOptions?: ResponseOptions) {
super();
if (req.method !== RequestMethod.Get) {
throw new TypeError(JSONP_ERR_WRONG_METHOD);
}
@ -129,6 +121,10 @@ export class JSONPConnection_ extends JSONPConnection {
});
}
/**
* Callback called when the JSONP request completes, to notify the application
* of the new data.
*/
finished(data?: any) {
// Don't leak connections
this._finished = true;
@ -143,15 +139,14 @@ export class JSONPConnection_ extends JSONPConnection {
*
* @deprecated use @angular/common/http instead
*/
export abstract class JSONPBackend extends ConnectionBackend {}
@Injectable()
export class JSONPBackend_ extends JSONPBackend {
export class JSONPBackend extends ConnectionBackend {
/** @internal */
constructor(private _browserJSONP: BrowserJsonp, private _baseResponseOptions: ResponseOptions) {
super();
}
createConnection(request: Request): JSONPConnection {
return new JSONPConnection_(request, this._browserJSONP, this._baseResponseOptions);
return new JSONPConnection(request, this._browserJSONP, this._baseResponseOptions);
}
}