/** * Defines the signature for the Callback that an EventSubscription should have. * * @param eventPayload Optional: The payload received with the event. * @param eventName Optional: The name of the received event. */ export type EventReceivedCallback = (eventPayload?: any, eventName?: string) => void | Promise; /** * Contains information about a subscription on the EventAggregator. * External services can use this information to manage their own subscriptions. */ export type Subscription = { /** * The Id under which the EventAggregator has stored the Subscription. */ readonly id: string; /** * The name of the event for which the Subscription was created. */ readonly eventName: string; /** * If set to true, the Subscription will be destroyed after first receiving * the event. */ readonly onlyReceiveOnce: boolean; }; declare function subscribe(eventName: string, callback: EventReceivedCallback): Subscription; declare function subscribeOnce(eventName: string, callback: EventReceivedCallback): Subscription; declare function publish(eventName: string, payload?: any, onAcknowledgement?: () => void, eventId?: string): void; declare function acknowledgeEvent(eventId: string): void; declare function unsubscribe(subscription: Subscription): void; declare function clear(): void; export declare const EventAggregator: { acknowledgeEvent: typeof acknowledgeEvent; subscribe: typeof subscribe; subscribeOnce: typeof subscribeOnce; publish: typeof publish; unsubscribe: typeof unsubscribe; /** * Clears all subscriptions currently registered on the Event Aggregator. * * CAUTION - Use this only for cleanup procedures during shutdown. DO NOT use this during normal operations! */ clear_UNSAFE: typeof clear; }; export default EventAggregator;