Skip to content

Commit

Permalink
chore: function storage
Browse files Browse the repository at this point in the history
  • Loading branch information
nigrosimone committed Oct 8, 2024
1 parent 2a5489b commit 986343d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
```

Expand Down
4 changes: 2 additions & 2 deletions projects/ng-http-caching-demo/src/main.ts
Original file line number Diff line number Diff line change
@@ -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()) {
Expand All @@ -11,7 +11,7 @@ if (!isDevMode()) {
bootstrapApplication(AppComponent, {
providers: [
provideNgHttpCaching({
store: new NgHttpCachingLocalStorage()
store: withNgHttpCachingLocalStorage()
}),
provideHttpClient(withInterceptorsFromDi())
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export class NgHttpCachingLocalStorage extends NgHttpCachingBrowserStorage {
super(localStorage);
}
}

export const withNgHttpCachingLocalStorage = () => new NgHttpCachingLocalStorage();
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export class NgHttpCachingSessionStorage extends NgHttpCachingBrowserStorage {
super(sessionStorage);
}
}

export const withNgHttpCachingSessionStorage = () => new NgHttpCachingSessionStorage();

0 comments on commit 986343d

Please sign in to comment.