UNPKG

ngx-json-ui

Version:

This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.

46 lines (45 loc) 2 kB
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs'; import * as i0 from "@angular/core"; /** * Global HTTP service that wraps Angular's HttpClient to manage a loading indicator. * It exposes a "loading$" observable that emits true when a request starts * and false when it completes (if showLoader is enabled), and delegates * actual requests to HttpClient. */ export interface HttpOptions { /** Whether to show a global loading spinner during this request */ showLoader?: boolean; /** Optional HTTP headers */ headers?: HttpHeaders; /** Optional query parameters */ params?: HttpParams; } export declare class HttpService { private http; /** * Internal subject tracking current loading state. When true, a loader is active. */ private loadingSubject; /** Observable consumers can subscribe to show/hide a global spinner */ loading$: Observable<boolean>; constructor(http: HttpClient); /** * Core request wrapper. * - If options.showLoader is true, emits loadingSubject.next(true) before the request * - Delegates to HttpClient.request<T> * - Uses finalize() to emit loadingSubject.next(false) when the request ends (success or error) */ private request; /** * Shortcut for GET requests. Builds HttpParams from a plain object. */ get<T>(url: string, params?: Record<string, any>, options?: HttpOptions): Observable<T>; /** Convenience methods for other HTTP verbs **/ post<T>(url: string, body: any, options?: HttpOptions): Observable<T>; put<T>(url: string, body: any, options?: HttpOptions): Observable<T>; patch<T>(url: string, body: any, options?: HttpOptions): Observable<T>; delete<T>(url: string, params?: Record<string, any>, options?: HttpOptions): Observable<T>; static ɵfac: i0.ɵɵFactoryDeclaration<HttpService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<HttpService>; }