UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

70 lines 2.85 kB
import { IIdentified } from '@c8y/client'; import { Observable } from 'rxjs'; import { RealtimeSubjectService } from './realtime-subject.service'; import { RealtimeMessage } from './realtime.model'; /** * A wrapper class for handling realtime notifications in RxJS fashion. */ export declare abstract class RealtimeService<T> { protected realtimeSubject: RealtimeSubjectService; /** * A flag displaying if realtime notifications are currently active. */ get active(): boolean; /** * An observable emitting a value in case the realtime connection has been interrupted. * Can be used to reload data of e.g. a datapoint graph that wasn't received while realtime was interrupted. */ get reconnect$(): Observable<void>; /** * An observable emitting either `connected` or `disconnected` depending on the state of the realtime connection. * Can be used to e.g. inform the user about the interrupted realtime connection. */ get connectionStatus$(): Observable<'connected' | 'disconnected'>; private isActive; constructor(realtimeSubject: RealtimeSubjectService); /** * Get an Observable of all realtime notifications. * * @param {string | number | IIdentified} entityOrId Entity object or id * * @returns An [[Observable]] of notifications wrapped as [[RealtimeMessage]] */ onAll$(entityOrId?: string | number | IIdentified): Observable<RealtimeMessage<T>>; /** * Subscribes again all realtime channels with active observers. */ start(): void; /** * Stops realtime notifications and unsubscribes all realtime channels. */ stop(): void; /** * Get an Observable of all CREATE realtime notifications. * * @param {string | number | IIdentified} entityOrId Entity object or id * * @returns An [[Observable]] of newly created entity objects. */ onCreate$(entityOrId?: string | number | IIdentified): Observable<T>; /** * Get an Observable of all UPDATE realtime notifications. * * @param {string | number | IIdentified} entityOrId Entity object or id * * @returns An [[Observable]] of updated entity objects. */ onUpdate$(entityOrId?: string | number | IIdentified): Observable<T>; /** * Get an Observable of all DELETE realtime notifications. * * @param {string | number | IIdentified} entityOrId Entity object or id * * @returns An [[Observable]] of deleted entity objects. */ onDelete$(entityOrId?: string | number | IIdentified): Observable<number>; protected getIdString(reference: number | string | IIdentified): string; protected getChannel(entityOrId?: string | number | IIdentified): string; protected abstract channel(): string; } //# sourceMappingURL=realtime.service.d.ts.map