UNPKG

ngx-endpoints

Version:

A library to dynamically load data from http endpoints / urls in angular

43 lines (42 loc) 1.44 kB
import { NgxEndpointService } from './ngx-endpoints.service'; import { NgxEndPointData } from './ngx-endpoint.format'; import { BehaviorSubject } from 'rxjs'; export declare class NgxEndPoint<T> { endpointservice: NgxEndpointService; protected _endpoint: NgxEndPointData; /** * raw data that is used for later identification of the endpoint */ endpoint: NgxEndPointData; /** * data stores the last requested data as Behaviorsubject that can be subscribed. */ data: BehaviorSubject<T>; /** * if a request is already pending no additional request should be made to the datasource */ requestPending: BehaviorSubject<any>; /** * Is the endpoint alive and returns data ? */ isAlive: BehaviorSubject<any>; /** * Delivering internal process information */ events: BehaviorSubject<string>; /** * for live sources this option will be used to stop the process */ running: boolean; constructor(endpointservice: NgxEndpointService, _endpoint: NgxEndPointData); /** * Requests data from an http source * Optionally converts relative dates (now-1d) into readable urls by DatesOutputFormat * Adds the result of the request to BehaviorSubject data that can be subscribed */ requestData(): Promise<void>; protected requestInternal(): Promise<void>; private convertDates; private request; private addEvent; }