-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e617f7
commit 45e3c3c
Showing
10 changed files
with
113 additions
and
156 deletions.
There are no files selected for viewing
10 changes: 0 additions & 10 deletions
10
projects/ng-http-caching-demo/src/app/app-routing.module.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { enableProdMode } from '@angular/core'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
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 { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; | ||
|
||
import { AppModule } from './app/app.module'; | ||
import { environment } from './environments/environment'; | ||
|
||
if (environment.production) { | ||
if (!isDevMode()) { | ||
enableProdMode(); | ||
} | ||
|
||
platformBrowserDynamic().bootstrapModule(AppModule) | ||
.catch(err => console.error(err)); | ||
bootstrapApplication(AppComponent, { | ||
providers: [ | ||
provideNgHttpCaching({ | ||
store: new NgHttpCachingLocalStorage() | ||
}), | ||
provideHttpClient(withInterceptorsFromDi()) | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
projects/ng-http-caching/src/lib/ng-http-caching-interceptor.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
projects/ng-http-caching/src/lib/ng-http-caching-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { EnvironmentProviders, makeEnvironmentProviders } from "@angular/core"; | ||
import { HTTP_INTERCEPTORS } from "@angular/common/http"; | ||
import { NgHttpCachingInterceptorService } from "./ng-http-caching-interceptor.service"; | ||
import { NG_HTTP_CACHING_CONFIG, NgHttpCachingConfig, NgHttpCachingService } from "./ng-http-caching.service"; | ||
|
||
export function provideNgHttpCaching(ngHttpCachingConfig?: NgHttpCachingConfig) { | ||
const providers: EnvironmentProviders[] = []; | ||
if (ngHttpCachingConfig) { | ||
providers.push(makeEnvironmentProviders([{ | ||
provide: NG_HTTP_CACHING_CONFIG, | ||
useValue: ngHttpCachingConfig, | ||
}])); | ||
} | ||
providers.push(makeEnvironmentProviders([ | ||
NgHttpCachingService, | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useClass: NgHttpCachingInterceptorService, | ||
multi: true, | ||
}, | ||
NgHttpCachingInterceptorService | ||
])); | ||
return providers; | ||
} |
Oops, something went wrong.