Skip to content

Commit

Permalink
fix(common): temporarily re-export and deprecate XhrFactory
Browse files Browse the repository at this point in the history
The `XhrFactory` still needs to be available from `@angular/common/http`
for some libraries that were built prior to 12.0.0, otherwise they cannot
be used in application built post-12.0.0.
  • Loading branch information
petebacondarwin committed Mar 31, 2021
1 parent a371646 commit 15d17bd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
5 changes: 4 additions & 1 deletion goldens/public-api/common/http/http.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,7 @@ export declare interface HttpUserEvent<T> {
}

export declare class HttpXhrBackend implements HttpBackend {
constructor(xhrFactory: XhrFactory);
constructor(xhrFactory: XhrFactory_2);
handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
}

Expand All @@ -1947,3 +1947,6 @@ export declare class JsonpInterceptor {
constructor(jsonp: JsonpClientBackend);
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
}

/** @deprecated */
export declare type XhrFactory = XhrFactory_2;
19 changes: 19 additions & 0 deletions packages/common/http/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@
* found in the LICENSE file at https://angular.io/license
*/

import {XhrFactory as XhrFactory_fromAngularCommon} from '@angular/common';

/**
* A wrapper around the `XMLHttpRequest` constructor.
* @publicApi
* @deprecated
* `XhrFactory`` has been moved to `@angular/common`, please update your code to import it from
* there.
*/
export type XhrFactory = XhrFactory_fromAngularCommon;
/**
* A wrapper around the `XMLHttpRequest` constructor.
* @publicApi
* @deprecated
* `XhrFactory`` has been moved to `@angular/common`, please update your code to import it from
* there.
*/
export const XhrFactory = XhrFactory_fromAngularCommon;

export {HttpBackend, HttpHandler} from './src/backend';
export {HttpClient} from './src/client';
export {HttpContext, HttpContextToken} from './src/context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {XhrFactory} from '@angular/common';
import {HttpBackend} from '@angular/common/http';
import {HttpBackend, XhrFactory} from '@angular/common/http';
import {ModuleWithProviders, NgModule, Type} from '@angular/core';

import {httpClientInMemBackendServiceFactory} from './http-client-in-memory-web-api-module';
Expand Down

0 comments on commit 15d17bd

Please sign in to comment.