ngs-request-tracker
is a library for tracking (requestTrackerInterceptor), storing (RequestTrackerService) and displaying statistics (RequestTrackerComponent) on all http requests.
- Track 'is loading': - for managing loaders or spinners in the UI during ongoing network operations.
- Track all requests stats - UI component for displaying statistics.
Install ngs-request-tracker
via npm:
npm install ngs-request-tracker
app.config.ts:
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(withInterceptors([requestTrackerInterceptor])) //add requestTrackerInterceptor interceptor
]
};
your.component.ts:
@Component({
selector: 'app-your',
template: `
<div *ngIf="requestTracker.isInProgress()">Loading...</div>
<div *ngIf="requestTracker.isInProgress$ | async">Loading...</div>
`,
imports: [AsyncPipe]
})
export class YourComponent {
constructor(public requestTracker: RequestTrackerService) {}
}
app.config.ts:
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(withInterceptors([requestTrackerInterceptor])) //add requestTrackerInterceptor interceptor
]
};
your.component.ts:
@Component({
selector: 'app-your',
standalone: true,
imports: [RequestTrackerComponent],
template: `
@if (isDevMode) {
<ngs-request-tracker
[xPosition]="'right'"
[yPosition]="'bottom'"
></ngs-request-tracker>
}
`,
styleUrl: './app.component.scss',
})
export class YourComponent {
isDevMode = isDevMode(); // use as desired
}
To contribute or use the library in development mode, you can clone the repository and install dependencies.
- Fork the repository
- Clone the repo, install dependencies
git clone https://github.com/andrei-shpileuski/ngs-request-tracker.git
cd ngs-request-tracker
npm install
- Create a new branch for your changes
- Submit a pull request with a detailed description of the changes