UNPKG

1.64 kBTypeScriptView Raw
1import Observable from 'zen-observable-ts';
2import { ConnectionState } from '../types/PubSub';
3declare type LinkedConnectionState = 'connected' | 'disconnected';
4declare type LinkedHealthState = 'healthy' | 'unhealthy';
5declare type LinkedConnectionStates = {
6 networkState: LinkedConnectionState;
7 connectionState: LinkedConnectionState | 'connecting';
8 intendedConnectionState: LinkedConnectionState;
9 keepAliveState: LinkedHealthState;
10};
11export declare const CONNECTION_CHANGE: {
12 [key in 'KEEP_ALIVE_MISSED' | 'KEEP_ALIVE' | 'CONNECTION_ESTABLISHED' | 'CONNECTION_FAILED' | 'CLOSING_CONNECTION' | 'OPENING_CONNECTION' | 'CLOSED' | 'ONLINE' | 'OFFLINE']: Partial<LinkedConnectionStates>;
13};
14export declare class ConnectionStateMonitor {
15 /**
16 * @private
17 */
18 private _linkedConnectionState;
19 private _linkedConnectionStateObservable;
20 private _linkedConnectionStateObserver;
21 private _networkMonitoringSubscription?;
22 private _initialNetworkStateSubscription?;
23 constructor();
24 /**
25 * Turn network state monitoring on if it isn't on already
26 */
27 private enableNetworkMonitoring;
28 /**
29 * Turn network state monitoring off if it isn't off already
30 */
31 private disableNetworkMonitoring;
32 /**
33 * Get the observable that allows us to monitor the connection state
34 *
35 * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates
36 */
37 get connectionStateObservable(): Observable<ConnectionState>;
38 record(statusUpdates: Partial<LinkedConnectionStates>): void;
39 private connectionStatesTranslator;
40}
41export {};