• Version 5.1.16
  • Published
  • 809 kB
  • 7 dependencies
  • Apache-2.0 license


npm i @aws-amplify/pubsub
yarn add @aws-amplify/pubsub
pnpm add @aws-amplify/pubsub


Pubsub category of aws-amplify





    variable PubSub

    const PubSub: PubSubClass;


      function mqttTopicMatch

      mqttTopicMatch: (filter: string, topic: string) => boolean;


        class AbstractPubSubProvider

        abstract class AbstractPubSubProvider<T extends ProviderOptions>
        implements PubSubProvider {}


          constructor(options: ProviderOptions);

            property options

            readonly options: ProviderOptions;

              method configure

              configure: (config: T) => T;

                method getCategory

                getCategory: () => string;

                  method getProviderName

                  abstract getProviderName: () => string;

                    method newClient

                    abstract newClient: (clientOptions: T) => Promise<any>;

                      method publish

                      abstract publish: (
                      topics: string[] | string,
                      msg: PubSubContent,
                      options?: T
                      ) => void;

                        method subscribe

                        abstract subscribe: (
                        topics: string[] | string,
                        options?: T
                        ) => Observable<PubSubContent>;

                          class AWSAppSyncRealTimeProvider

                          class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider<AWSAppSyncRealTimeProviderOptions> {}


                            constructor(options?: ProviderOptions);

                              property isSSLEnabled

                              readonly isSSLEnabled: boolean;

                                method close

                                close: () => void;
                                • Mark the socket closed and release all active listeners

                                method getNewWebSocket

                                getNewWebSocket: (url: string, protocol: string) => WebSocket;

                                  method getProviderName

                                  getProviderName: () => string;

                                    method newClient

                                    newClient: () => Promise<any>;

                                      method publish

                                      publish: (
                                      _topics: string[] | string,
                                      _msg: PubSubContent,
                                      _options?: AWSAppSyncRealTimeProviderOptions
                                      ) => Promise<void>;

                                        method subscribe

                                        subscribe: (
                                        _topics: string[] | string,
                                        options?: AWSAppSyncRealTimeProviderOptions
                                        ) => Observable<Record<string, unknown>>;

                                          class AWSIoTProvider

                                          class AWSIoTProvider extends MqttOverWSProvider {}


                                            constructor(options?: AWSIoTProviderOptions);

                                              property endpoint

                                              readonly endpoint: Promise<string>;

                                                property region

                                                readonly region: string;

                                                  method getProviderName

                                                  getProviderName: () => string;

                                                    class MqttOverWSProvider

                                                    class MqttOverWSProvider extends AbstractPubSubProvider<MqttProviderOptions> {}


                                                      constructor(options?: MqttProviderOptions);

                                                        property clientId

                                                        readonly clientId: string;

                                                          property clientsQueue

                                                          readonly clientsQueue: ClientsQueue;

                                                            property endpoint

                                                            readonly endpoint: Promise<string>;

                                                              property isSSLEnabled

                                                              readonly isSSLEnabled: boolean;

                                                                method connect

                                                                protected connect: (
                                                                clientId: string,
                                                                options?: MqttProviderOptions
                                                                ) => Promise<PahoClient | undefined>;

                                                                  method disconnect

                                                                  protected disconnect: (clientId: string) => Promise<void>;

                                                                    method getProviderName

                                                                    getProviderName: () => string;

                                                                      method newClient

                                                                      newClient: ({ url, clientId }: MqttProviderOptions) => Promise<PahoClient>;

                                                                        method onDisconnect

                                                                        onDisconnect: ({
                                                                        }: {
                                                                        clientId?: string;
                                                                        errorCode?: number;
                                                                        }) => void;

                                                                          method publish

                                                                          publish: (topics: string[] | string, msg: PubSubContent) => Promise<void>;

                                                                            method subscribe

                                                                            subscribe: (
                                                                            topics: string[] | string,
                                                                            options?: MqttProviderOptions
                                                                            ) => Observable<PubSubContent>;


                                                                              interface AWSAppSyncRealTimeProviderOptions

                                                                              interface AWSAppSyncRealTimeProviderOptions extends ProviderOptions {}

                                                                                property additionalHeaders

                                                                                additionalHeaders?: {
                                                                                [key: string]: string;

                                                                                  property apiKey

                                                                                  apiKey?: string;

                                                                                    property appSyncGraphqlEndpoint

                                                                                    appSyncGraphqlEndpoint?: string;

                                                                                      property authenticationType

                                                                                      authenticationType?: GraphqlAuthModes;

                                                                                        property graphql_headers

                                                                                        graphql_headers?: () => {} | (() => Promise<{}>);

                                                                                          property query

                                                                                          query?: string;

                                                                                            property region

                                                                                            region?: string;

                                                                                              property variables

                                                                                              variables?: Record<string, unknown>;

                                                                                                interface AWSIoTProviderOptions

                                                                                                interface AWSIoTProviderOptions extends MqttProviderOptions {}

                                                                                                  property aws_pubsub_endpoint

                                                                                                  aws_pubsub_endpoint?: string;

                                                                                                    property aws_pubsub_region

                                                                                                    aws_pubsub_region?: string;

                                                                                                      interface MqttProviderOptions

                                                                                                      interface MqttProviderOptions extends ProviderOptions {}

                                                                                                        property aws_pubsub_endpoint

                                                                                                        aws_pubsub_endpoint?: string;

                                                                                                          property clientId

                                                                                                          clientId?: string;

                                                                                                            property url

                                                                                                            url?: string;


                                                                                                              enum ConnectionState

                                                                                                              enum ConnectionState {
                                                                                                              Connected = 'Connected',
                                                                                                              ConnectedPendingNetwork = 'ConnectedPendingNetwork',
                                                                                                              ConnectionDisrupted = 'ConnectionDisrupted',
                                                                                                              ConnectionDisruptedPendingNetwork = 'ConnectionDisruptedPendingNetwork',
                                                                                                              Connecting = 'Connecting',
                                                                                                              ConnectedPendingDisconnect = 'ConnectedPendingDisconnect',
                                                                                                              Disconnected = 'Disconnected',
                                                                                                              ConnectedPendingKeepAlive = 'ConnectedPendingKeepAlive',
                                                                                                              • {string}

                                                                                                              member Connected

                                                                                                              Connected = 'Connected'

                                                                                                                member ConnectedPendingDisconnect

                                                                                                                ConnectedPendingDisconnect = 'ConnectedPendingDisconnect'

                                                                                                                  member ConnectedPendingKeepAlive

                                                                                                                  ConnectedPendingKeepAlive = 'ConnectedPendingKeepAlive'

                                                                                                                    member ConnectedPendingNetwork

                                                                                                                    ConnectedPendingNetwork = 'ConnectedPendingNetwork'

                                                                                                                      member Connecting

                                                                                                                      Connecting = 'Connecting'

                                                                                                                        member ConnectionDisrupted

                                                                                                                        ConnectionDisrupted = 'ConnectionDisrupted'

                                                                                                                          member ConnectionDisruptedPendingNetwork

                                                                                                                          ConnectionDisruptedPendingNetwork = 'ConnectionDisruptedPendingNetwork'

                                                                                                                            member Disconnected

                                                                                                                            Disconnected = 'Disconnected'

                                                                                                                              enum CONTROL_MSG

                                                                                                                              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',

                                                                                                                                member CONNECTION_CLOSED

                                                                                                                                CONNECTION_CLOSED = 'Connection closed'

                                                                                                                                  member CONNECTION_FAILED

                                                                                                                                  CONNECTION_FAILED = 'Connection failed'

                                                                                                                                    member REALTIME_SUBSCRIPTION_INIT_ERROR

                                                                                                                                    REALTIME_SUBSCRIPTION_INIT_ERROR = 'AppSync Realtime subscription init error'

                                                                                                                                      member SUBSCRIPTION_ACK

                                                                                                                                      SUBSCRIPTION_ACK = 'Subscription ack'

                                                                                                                                        member TIMEOUT_DISCONNECT

                                                                                                                                        TIMEOUT_DISCONNECT = 'Timeout disconnect'

                                                                                                                                          Type Aliases

                                                                                                                                          type ObserverQuery

                                                                                                                                          type ObserverQuery = {
                                                                                                                                          observer: PubSubContentObserver;
                                                                                                                                          query: string;
                                                                                                                                          variables: Record<string, unknown>;
                                                                                                                                          subscriptionState: SUBSCRIPTION_STATUS;
                                                                                                                                          subscriptionReadyCallback?: Function;
                                                                                                                                          subscriptionFailedCallback?: Function;
                                                                                                                                          startAckTimeoutId?: ReturnType<typeof setTimeout>;

                                                                                                                                            Package Files (8)

                                                                                                                                            Dependencies (7)

                                                                                                                                            Dev Dependencies (2)

                                                                                                                                            Peer Dependencies (0)

                                                                                                                                            No peer dependencies.


                                                                                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@aws-amplify/pubsub.

                                                                                                                                            • Markdown
                                                                                                                                            • HTML
                                                                                                                                              <a href="https://www.jsdocs.io/package/@aws-amplify/pubsub"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>