UNPKG

810 BPlain TextView Raw
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3// import '../Common/Polyfills';
4import Observable from 'zen-observable-ts';
5
6import {
7 Amplify,
8 browserOrNode,
9 ConsoleLogger as Logger,
10} from '@aws-amplify/core';
11import { PubSubProvider, ProviderOptions } from './types';
12import { InternalPubSubClass } from './internals';
13
14type PubSubObservable = {
15 provider: PubSubProvider;
16 value: string | Record<string, unknown>;
17};
18
19export class PubSubClass extends InternalPubSubClass {
20 public getModuleName() {
21 return 'PubSub';
22 }
23
24 subscribe(
25 topics: string[] | string,
26 options?: ProviderOptions
27 ): Observable<PubSubObservable> {
28 return super.subscribe(topics, options);
29 }
30}
31
32export const PubSub = new PubSubClass();
33Amplify.register(PubSub);