Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
refactor: deprecate transfer http cache
Browse files Browse the repository at this point in the history
This commit deprecates a number of APIs.

DEPRECATED:
`StateTransferInitializerModule`, `TransferHttpCacheInterceptor` and `domContentLoadedFactory` have been deprecated in favor of `provideClientHydration`. See: https://angular.io/api/platform-browser/provideClientHydration
  • Loading branch information
alan-agius4 committed Jun 1, 2023
1 parent b771ef1 commit ccc2f52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/common/src/state-transfer-initializer/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# State Transfer Initializer

## Deprecated Use [`provideClientHydration`](https://angular.io/api/platform-browser/provideClientHydration) instead which caches HTTP requests by default.

Delays the app bootstrap process to ensure that the DOM content is loaded before state transfer initilization

Simply import the module into your project and you will no longer need to wrap your component bootstrap function in an `DOMContentLoaded` callback
Expand Down
8 changes: 8 additions & 0 deletions modules/common/src/state-transfer-initializer/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import { DOCUMENT } from '@angular/common';
import { APP_INITIALIZER, NgModule } from '@angular/core';

/**
* @deprecated Use `provideClientHydration` instead which caches HTTP requests by default.
* @see https://angular.io/api/platform-browser/provideClientHydration
*/
export function domContentLoadedFactory(doc: Document): () => Promise<void> {
return () =>
new Promise((resolve, _reject) => {
Expand All @@ -27,6 +31,10 @@ export function domContentLoadedFactory(doc: Document): () => Promise<void> {
});
}

/**
* @deprecated Use `provideClientHydration` instead which caches HTTP requests by default.
* @see https://angular.io/api/platform-browser/provideClientHydration
*/
@NgModule({
providers: [
{
Expand Down
4 changes: 4 additions & 0 deletions modules/common/src/transfer_http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function getHeadersMap(headers: HttpHeaders): Record<string, string[]> {
return headersMap;
}

/**
* @deprecated Use `provideClientHydration` instead which caches HTTP requests by default.
* @see https://angular.io/api/platform-browser/provideClientHydration
*/
@Injectable()
export class TransferHttpCacheInterceptor implements HttpInterceptor {
private isCacheActive = true;
Expand Down

0 comments on commit ccc2f52

Please sign in to comment.