Toggle navigation
P3X GitList Snapshot
GitHub
Repo
Changelog
To do
Releases
Themes
Change log
Loading change log ...
To do ...
Loading todo ...
browsing:
3167716c7e8757ade843c1f650872fa12d4b7d8e
Branches
master
Files
Commits
Log
Graph
Stats
angular-http-cache-interceptor.git
src
app
common
default-component
default-component.component.ts
RSS
Git
Fetch origin
Download
ZIP
TAR
Clone
Raw
View
History
Clone
SSH
HTTPS
Blames found: 21
Mode: application/typescript
Binary: false
Hang on, we reloading big blames...
248ac3a3
import {Component, ViewEncapsulation} from '@angular/core'; import { HttpClient } from "@angular/common/http";
d9893f5d
import {MatSnackBar, MatSnackBarConfig} from "@angular/material/snack-bar";
248ac3a3
import { CachingHeaders} from "../../../../projects/angular-http-cache-interceptor/src/lib/caching-headers.enum";
4362659f
import { MatDividerModule } from '@angular/material/divider'; import { MatButtonModule } from '@angular/material/button';
248ac3a3
@Component({
4362659f
selector: 'p3x-default-component', templateUrl: './default-component.component.html', styleUrls: ['./default-component.component.scss'], standalone: true, imports: [MatButtonModule, MatDividerModule],
248ac3a3
}) export class DefaultComponentComponent {
d9893f5d
defaultSnackbarSettings : MatSnackBarConfig = { horizontalPosition: "center", verticalPosition: "bottom" }
248ac3a3
constructor( private http: HttpClient, private snack: MatSnackBar, ) { } async loadDefault() { try { const response : any = await this.http.get('https://server.patrikx3.com/api/core/util/random/32').toPromise()
81262c82
this.snack.open(`The output is based on the default interceptor behavior: ${response.random}`, 'OK', this.defaultSnackbarSettings)
248ac3a3
} catch(e) {
d9893f5d
this.snack.open(`Sorry, error happened, check the console for the error`, 'OK', this.defaultSnackbarSettings)
248ac3a3
console.error(e) } } async loadCached() { try { const response : any = await this.http.get('https://server.patrikx3.com/api/core/util/random/32', { headers: { [CachingHeaders.Cache]: '1', } }).toPromise()
d9893f5d
this.snack.open(`Will be always the same output: ${response.random}`, 'OK', this.defaultSnackbarSettings)
248ac3a3
} catch(e) {
d9893f5d
this.snack.open(`Sorry, error happened, check the console for the error`, 'OK', this.defaultSnackbarSettings)
248ac3a3
console.error(e) } } async loadNonCached() { try { const response : any = await this.http.get('https://server.patrikx3.com/api/core/util/random/16', { headers: { [CachingHeaders.NoCache]: '1', } }).toPromise()
d9893f5d
this.snack.open(`Truly random data: ${response.random}`, 'OK', this.defaultSnackbarSettings)
248ac3a3
} catch(e) {
d9893f5d
this.snack.open(`Sorry, error happened, check the console for the error`, 'OK', this.defaultSnackbarSettings)
248ac3a3
console.error(e) } } }