UNPKG

1.6 kBTypeScriptView Raw
1import { Observable, Observer } from 'rxjs';
2export interface SubscriptionObserver<T> {
3 closed: boolean;
4 next(value: T): void;
5 error(errorValue: any): void;
6 complete(): void;
7}
8export declare enum CONTROL_MSG {
9 CONNECTION_CLOSED = "Connection closed",
10 CONNECTION_FAILED = "Connection failed",
11 REALTIME_SUBSCRIPTION_INIT_ERROR = "AppSync Realtime subscription init error",
12 SUBSCRIPTION_ACK = "Subscription ack",
13 TIMEOUT_DISCONNECT = "Timeout disconnect"
14}
15/** @enum {string} */
16export declare enum ConnectionState {
17 Connected = "Connected",
18 ConnectedPendingNetwork = "ConnectedPendingNetwork",
19 ConnectionDisrupted = "ConnectionDisrupted",
20 ConnectionDisruptedPendingNetwork = "ConnectionDisruptedPendingNetwork",
21 Connecting = "Connecting",
22 ConnectedPendingDisconnect = "ConnectedPendingDisconnect",
23 Disconnected = "Disconnected",
24 ConnectedPendingKeepAlive = "ConnectedPendingKeepAlive"
25}
26export type PubSubContent = Record<string | symbol, unknown>;
27export type PubSubContentObserver = Observer<PubSubContent>;
28export interface PubSubOptions {
29 [key: string]: any;
30 provider?: string | symbol;
31}
32export interface PubSubBase {
33 configure(config: Record<string, unknown>): Record<string, unknown>;
34 publish(input: PublishInput): void;
35 subscribe(input: SubscribeInput): Observable<PubSubContent>;
36}
37export interface PublishInput {
38 topics: string[] | string;
39 message: PubSubContent;
40 options?: PubSubOptions;
41}
42export interface SubscribeInput {
43 topics: string[] | string;
44 options?: PubSubOptions;
45}