UNPKG

@aws-amplify/core

Version:
47 lines (46 loc) 2.04 kB
import { AmplifyChannel, AmplifyEventData, EventDataMap, HubCallback, HubPayload, StopListenerCallback } from './types'; export declare const AMPLIFY_SYMBOL: symbol; export declare class HubClass { name: string; private listeners; protectedChannels: string[]; constructor(name: string); /** * Used internally to remove a Hub listener. * * @remarks * This private method is for internal use only. Instead of calling Hub.remove, call the result of Hub.listen. */ private _remove; /** * Used to send a Hub event. * * @param channel - The channel on which the event will be broadcast * @param payload - The HubPayload * @param source - The source of the event; defaults to '' * @param ampSymbol - Symbol used to determine if the event is dispatched internally on a protected channel * */ dispatch<Channel extends AmplifyChannel>(channel: Channel, payload: HubPayload<AmplifyEventData[Channel]>, source?: string, ampSymbol?: symbol): void; dispatch(channel: string, payload: HubPayload, source?: string, ampSymbol?: symbol): void; /** * Used to listen for Hub events. * * @param channel - The channel on which to listen * @param callback - The callback to execute when an event is received on the specified channel * @param listenerName - The name of the listener; defaults to 'noname' * @returns A function which can be called to cancel the listener. * */ listen<Channel extends AmplifyChannel>(channel: Channel, callback: HubCallback<Channel, AmplifyEventData[Channel]>, listenerName?: string): StopListenerCallback; listen<EventData extends EventDataMap>(channel: string, callback: HubCallback<string, EventData>, listenerName?: string): StopListenerCallback; private _toListeners; } export declare const Hub: HubClass; /** * @internal * * Internal hub used for core Amplify functionality. Not intended for use outside of Amplify. * */ export declare const HubInternal: HubClass;