UNPKG

ngx-sse-client

Version:

A simple SSE (Server Sent Events) client for Angular applications.

43 lines (42 loc) 1.75 kB
import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { SseRequestOptions } from './sse-request-options.interface'; import * as i0 from "@angular/core"; export declare class SseClient { private httpClient; constructor(httpClient: HttpClient); /** * Constructs a request which listen to the SSE and interprets the data as * events and returns the full event stream. * * @param url the endpoint URL. * @param options an object of `SseOption` * @param requestOptions the HTTP options to send with the request. * @param method the HTTP method * * @returns an observable of all events for the request, with the response body of type `Event`. */ stream(url: string, options?: { keepAlive?: boolean; reconnectionDelay?: number; responseType?: 'event'; }, requestOptions?: SseRequestOptions, method?: string): Observable<Event>; /** * Constructs a request which listen to the SSE and interprets the data as a * string text and returns the full event stream. * * @param url the endpoint URL. * @param options an object of `SseOption` * @param requestOptions the HTTP options to send with the request. * @param method the HTTP method * * @returns an observable of all events for the request, with the response body of type string. */ stream(url: string, options?: { keepAlive?: boolean; reconnectionDelay?: number; responseType?: 'text'; }, requestOptions?: SseRequestOptions, method?: string): Observable<string>; static ɵfac: i0.ɵɵFactoryDeclaration<SseClient, never>; static ɵprov: i0.ɵɵInjectableDeclaration<SseClient>; }