1 |
|
2 |
|
3 |
|
4 | import Observable from 'zen-observable-ts';
|
5 |
|
6 | import {
|
7 | Amplify,
|
8 | browserOrNode,
|
9 | ConsoleLogger as Logger,
|
10 | } from '@aws-amplify/core';
|
11 | import { PubSubProvider, ProviderOptions } from './types';
|
12 | import { InternalPubSubClass } from './internals';
|
13 |
|
14 | type PubSubObservable = {
|
15 | provider: PubSubProvider;
|
16 | value: string | Record<string, unknown>;
|
17 | };
|
18 |
|
19 | export 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 |
|
32 | export const PubSub = new PubSubClass();
|
33 | Amplify.register(PubSub);
|