import { Types } from ".."; import { ConnectionStatusEventType, ConnectionSubscription, EventCallback, SubscriberForEvents, SubscriberForInboxEvents, SubscriberForKvdbEvents, SubscriberForStoreEvents, SubscriberForThreadsEvents, SubscriberForUserEvents, Subscription } from "./subscriptions"; /** * * General usage * * const fn1 = () =>{} * const fn2 = () =>{} * * const fn3 = () =>{} * * * const subscriptionA = createSubscription({ * type: Types.ThreadEventType.THREAD_CREATE, * selector: Types.ThreadEventSelectorType.THREAD_CONTAINER, * selectorId: "s0dvos0div0smidvmsd" * callbacks: [fn1,fn2] * }) * * const subscriptionB = createThreadSubscribtion({ * type: Types.ThreadEventType.MESSAGE_CREATED, * selector: Types.ThreadEventSelectorType.CONTEXT_CONTAINER, * selectorId: "s0dvos0div0smidvmsd" * callbacks: [fn3] * }) * * await manager.subscribeFor([subscriptionA, subscriptionB]) * * * await manager.unsubscribeFrom(subscriptionB) * * --- or --- * * await manager.removeCallback(subscriptionA.callbacks[0]) */ export type Channel = "inbox" | `inbox/${string}/entries` | "store" | `store/${string}/files` | "thread" | `thread/${string}/messages` | `connection/${string}` | "context/userAdded" | "context/userRemoved" | "context/userStatus" | `context/${string}/${string}`; export interface GenericEvent extends Types.Event { /** * Data associated with the event. */ data: K; } export declare abstract class BaseEventDispatcherManager { private _listenersSymbols; private _listeners; get listeners(): Map; protected abstract apiSubscribeFor(strings: string[]): Promise; protected abstract apiUnsubscribeFrom(strings: string[]): Promise; dispatchEvent(event: Types.Event): void; unregisterCallback(symbol: Symbol): void; protected prepareSubscription(channelList: string[], subscriptions: { callbacks: EventCallback[]; }[]): Promise; unsubscribeFrom(subscriptionsId: string[]): Promise; } export declare class ThreadEventsManager extends BaseEventDispatcherManager { private threadApi; constructor(threadApi: SubscriberForThreadsEvents); protected apiSubscribeFor(channels: string[]): Promise; protected apiUnsubscribeFrom(subscriptionId: string[]): Promise; subscribeFor(subscriptions: Subscription[]): Promise; } export declare class StoreEventsManager extends BaseEventDispatcherManager { private storeApi; constructor(storeApi: SubscriberForStoreEvents); protected apiSubscribeFor(channels: string[]): Promise; protected apiUnsubscribeFrom(subscriptionId: string[]): Promise; subscribeFor(subscriptions: Subscription[]): Promise; } export declare class InboxEventsManager extends BaseEventDispatcherManager { private inboxApi; constructor(inboxApi: SubscriberForInboxEvents); protected apiSubscribeFor(channels: string[]): Promise; protected apiUnsubscribeFrom(subscriptionId: string[]): Promise; subscribeFor(subscriptions: Subscription[]): Promise; } export declare class KvdbEventsManager extends BaseEventDispatcherManager { private kvdbApi; constructor(kvdbApi: SubscriberForKvdbEvents); protected apiSubscribeFor(channels: string[]): Promise; protected apiUnsubscribeFrom(subscriptionId: string[]): Promise; subscribeFor(subscriptions: Subscription[]): Promise; } export declare class CustomEventsManager extends BaseEventDispatcherManager { private eventsApi; constructor(eventsApi: SubscriberForEvents); protected apiSubscribeFor(channels: string[]): Promise; protected apiUnsubscribeFrom(subscriptionId: string[]): Promise; subscribeFor(subscriptions: Subscription[]): Promise; } export declare const ConnectionChannels: Record; export declare class ConnectionEventsManager extends BaseEventDispatcherManager { private connectionId; constructor(connectionId: string); protected apiSubscribeFor(channels: string[]): Promise; protected apiUnsubscribeFrom(): Promise; subscribeFor(subscriptions: ConnectionSubscription[]): Promise; } export declare class UserEventsManager extends BaseEventDispatcherManager { private userEventsApi; constructor(userEventsApi: SubscriberForUserEvents); protected apiSubscribeFor(channels: string[]): Promise; protected apiUnsubscribeFrom(subscriptionId: string[]): Promise; subscribeFor(subscriptions: Subscription[]): Promise; }