-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
PubSub.ts
58 lines (54 loc) · 1.65 KB
/
PubSub.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { ZenObservable } from 'zen-observable-ts';
export interface SubscriptionObserver<T> {
closed: boolean;
next(value: T): void;
error(errorValue: any): void;
complete(): void;
}
export enum CONTROL_MSG {
CONNECTION_CLOSED = 'Connection closed',
CONNECTION_FAILED = 'Connection failed',
REALTIME_SUBSCRIPTION_INIT_ERROR = 'AppSync Realtime subscription init error',
SUBSCRIPTION_ACK = 'Subscription ack',
TIMEOUT_DISCONNECT = 'Timeout disconnect',
}
/** @enum {string} */
export enum ConnectionState {
/*
* The connection is alive and healthy
*/
Connected = 'Connected',
/*
* The connection is alive, but the connection is offline
*/
ConnectedPendingNetwork = 'ConnectedPendingNetwork',
/*
* The connection has been disconnected while in use
*/
ConnectionDisrupted = 'ConnectionDisrupted',
/*
* The connection has been disconnected and the network is offline
*/
ConnectionDisruptedPendingNetwork = 'ConnectionDisruptedPendingNetwork',
/*
* The connection is in the process of connecting
*/
Connecting = 'Connecting',
/*
* The connection is not in use and is being disconnected
*/
ConnectedPendingDisconnect = 'ConnectedPendingDisconnect',
/*
* The connection is not in use and has been disconnected
*/
Disconnected = 'Disconnected',
/*
* The connection is alive, but a keep alive message has been missed
*/
ConnectedPendingKeepAlive = 'ConnectedPendingKeepAlive',
}
export type PubSubContent = Record<string, unknown> | string;
export type PubSubContentObserver =
ZenObservable.SubscriptionObserver<PubSubContent>;