UNPKG

1.8 kBTypeScriptView Raw
1import Observable from 'zen-observable-ts';
2import { PubSubProvider, PubSubOptions, ProviderOptions } from './types';
3import { PubSubContent } from './types/PubSub';
4declare type PubSubObservable = {
5 provider: PubSubProvider;
6 value: string | Record<string, unknown>;
7};
8export declare class PubSubClass {
9 private _options;
10 private _pluggables;
11 /**
12 * Internal instance of AWSAppSyncRealTimeProvider used by the API category to subscribe to AppSync
13 */
14 private _awsAppSyncRealTimeProvider?;
15 /**
16 * Lazy instantiate AWSAppSyncRealTimeProvider when it is required by the API category
17 */
18 private get awsAppSyncRealTimeProvider();
19 /**
20 * Initialize PubSub with AWS configurations
21 *
22 * @param {PubSubOptions} options - Configuration object for PubSub
23 */
24 constructor(options?: PubSubOptions);
25 getModuleName(): string;
26 /**
27 * Configure PubSub part with configurations
28 *
29 * @param {PubSubOptions} config - Configuration for PubSub
30 * @return {Object} - The current configuration
31 */
32 configure(options: PubSubOptions): PubSubOptions;
33 /**
34 * add plugin into Analytics category
35 * @param {Object} pluggable - an instance of the plugin
36 */
37 addPluggable(pluggable: PubSubProvider): Promise<Record<string, unknown>>;
38 /**
39 * remove plugin from PubSub category
40 * @param providerName - the name of the plugin
41 */
42 removePluggable(providerName: string): void;
43 private getProviderByName;
44 private getProviders;
45 publish(topics: string[] | string, msg: PubSubContent, options?: ProviderOptions): Promise<void[]>;
46 subscribe(topics: string[] | string, options?: ProviderOptions): Observable<PubSubObservable>;
47}
48export declare const PubSub: PubSubClass;
49export {};