diff --git a/README.md b/README.md index 6162b34..255e07b 100644 --- a/README.md +++ b/README.md @@ -120,23 +120,23 @@ const ngHttpCachingConfig: NgHttpCachingConfig = { }; ``` -there is also a `NgHttpCachingLocalStorage` a cache store with persistence into `localStorage`: +there is also a `withNgHttpCachingLocalStorage` a cache store with persistence into `localStorage`: ```ts -import { NgHttpCachingConfig, NgHttpCachingLocalStorage } from 'ng-http-caching'; +import { NgHttpCachingConfig, withNgHttpCachingLocalStorage } from 'ng-http-caching'; const ngHttpCachingConfig: NgHttpCachingConfig = { - store: new NgHttpCachingLocalStorage(), + store: withNgHttpCachingLocalStorage(), }; ``` -and a `NgHttpCachingSessionStorage` a cache store with persistence into `sessionStorage`: +and a `withNgHttpCachingSessionStorage` a cache store with persistence into `sessionStorage`: ```ts -import { NgHttpCachingConfig, NgHttpCachingSessionStorage } from 'ng-http-caching'; +import { NgHttpCachingConfig, withNgHttpCachingSessionStorage } from 'ng-http-caching'; const ngHttpCachingConfig: NgHttpCachingConfig = { - store: new NgHttpCachingSessionStorage(), + store: withNgHttpCachingSessionStorage(), }; ``` diff --git a/projects/ng-http-caching-demo/src/main.ts b/projects/ng-http-caching-demo/src/main.ts index f8f3754..fe6aec7 100644 --- a/projects/ng-http-caching-demo/src/main.ts +++ b/projects/ng-http-caching-demo/src/main.ts @@ -1,7 +1,7 @@ import { enableProdMode, isDevMode } from '@angular/core'; import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app/app.component'; -import { NgHttpCachingLocalStorage, provideNgHttpCaching } from 'projects/ng-http-caching/src/public-api'; +import { withNgHttpCachingLocalStorage, provideNgHttpCaching } from 'projects/ng-http-caching/src/public-api'; import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; if (!isDevMode()) { @@ -11,7 +11,7 @@ if (!isDevMode()) { bootstrapApplication(AppComponent, { providers: [ provideNgHttpCaching({ - store: new NgHttpCachingLocalStorage() + store: withNgHttpCachingLocalStorage() }), provideHttpClient(withInterceptorsFromDi()) ] diff --git a/projects/ng-http-caching/src/lib/storage/ng-http-caching-local-storage.ts b/projects/ng-http-caching/src/lib/storage/ng-http-caching-local-storage.ts index cec8206..9896e87 100644 --- a/projects/ng-http-caching/src/lib/storage/ng-http-caching-local-storage.ts +++ b/projects/ng-http-caching/src/lib/storage/ng-http-caching-local-storage.ts @@ -6,3 +6,5 @@ export class NgHttpCachingLocalStorage extends NgHttpCachingBrowserStorage { super(localStorage); } } + +export const withNgHttpCachingLocalStorage = () => new NgHttpCachingLocalStorage(); \ No newline at end of file diff --git a/projects/ng-http-caching/src/lib/storage/ng-http-caching-session-storage.ts b/projects/ng-http-caching/src/lib/storage/ng-http-caching-session-storage.ts index 0f6d5aa..0de7ab5 100644 --- a/projects/ng-http-caching/src/lib/storage/ng-http-caching-session-storage.ts +++ b/projects/ng-http-caching/src/lib/storage/ng-http-caching-session-storage.ts @@ -6,3 +6,5 @@ export class NgHttpCachingSessionStorage extends NgHttpCachingBrowserStorage { super(sessionStorage); } } + +export const withNgHttpCachingSessionStorage = () => new NgHttpCachingSessionStorage(); \ No newline at end of file