Skip to content

Commit 72277bd

Browse files
committed
fix: reverted adding withHttpBackend
the new function practically saves the user 4 characters while adding a new function to the library with no practical use. ~~~ TranslateHttpLoader.withHttpBackend(httpBackend, '/assets/i18n/', '.json'), ~~~ vs ~~~ new TranslateHttpLoader(new HttpClient(httpBackend), '/assets/i18n/', '.json'), ~~~ It makes more sense to add this to the documentation.
1 parent 34ff089 commit 72277bd

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

projects/http-loader/src/lib/http-loader-backend.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
HTTP_INTERCEPTORS,
3-
HttpBackend,
3+
HttpBackend, HttpClient,
44
provideHttpClient,
55
withInterceptorsFromDi
66
} from "@angular/common/http";
@@ -32,7 +32,7 @@ describe('TranslateLoader (HttpBackend)', () => {
3232
loader: {
3333
provide: TranslateLoader,
3434
useFactory: (httpBackend: HttpBackend) =>
35-
TranslateHttpLoader.withHttpBackend(httpBackend, '/assets/i18n/', '.json'),
35+
new TranslateHttpLoader(new HttpClient(httpBackend), '/assets/i18n/', '.json'),
3636
deps: [HttpBackend],
3737
}
3838
}),

projects/http-loader/src/lib/http-loader.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {TranslateLoader, TranslationObject} from "@ngx-translate/core";
2-
import {HttpBackend, HttpClient} from "@angular/common/http";
2+
import {HttpClient} from "@angular/common/http";
33
import {Inject, Injectable} from "@angular/core";
44
import {Observable} from 'rxjs';
55

@@ -16,15 +16,6 @@ export class TranslateHttpLoader implements TranslateLoader {
1616
)
1717
{}
1818

19-
public static withHttpBackend(
20-
backend: HttpBackend,
21-
prefix: string = TranslateHttpLoader.defaultPrefix,
22-
suffix: string = TranslateHttpLoader.defaultSuffix
23-
): TranslateHttpLoader
24-
{
25-
return new TranslateHttpLoader(new HttpClient(backend), prefix, suffix);
26-
}
27-
2819
/**
2920
* Gets the translations from the server
3021
*/

0 commit comments

Comments
 (0)