/** * @description * Exposes utility APIs in the Constellation Core that publish and subscribe events */ declare class PubSubUtils { /** * Notifies the subscription item(which can be uniquely identified by subscriptionItemName) * whenever a specific type of event occurs * * @example Example for subscribe() * Example usage - PCore.getPubSubUtils().subscribe("showCancelAlert",()=>{},"createStageCancelAlert",false,"app/primary_1"); * // notifies the createStageCancelAlert function whenever an event of type showCancelAlert occurs * @param eventType - The type of event * @param subscriptionItem - The callback function that is invoked when a specific type of event occurs. * @param subscriptionItemName - A unique ID or name assigned by the user to identify the subscription item. * @param subscribeOnce - The flag that determines if the subscription item should be notified only once. * @param contextName - The name of the context containing the event whose subscription item must be notified. eq., app/primary_1 * @function */ static subscribe(eventType: string, subscriptionItem: Function, subscriptionItemName?: string, subscribeOnce?: boolean, contextName?: string): void; /** * Notifies the subscription item(which can be uniquely identified by subscriptionItemName) only once * whenever a specific type of event occurs * * @example Example for subscribeOnce() * Example usage - PCore.getPubSubUtils().subscribeOnce("showCancelAlert",()=>{},"createStageCancelAlert"); * // Notifies the createStageCancelAlert function only once when an event of type showCancelAlert occurs * @param eventType - The type of event * @param subscriptionItem - The callback function that is invoked only once when a specific type of event occurs. * @param subscriptionItemName - The unique name or ID used to identify the subscription item. * @function */ static subscribeOnce(eventType: string, subscriptionItem: Function, subscriptionItemName: string): void; /** * Invokes all items subscribed to a specific type of event and * passes the specified payload to the subscribed items * * @example Example for publish * Example usage - PCore.getPubSubUtils().publish(eventType,payload); * // invokes all items subscribed to the event type and passes the payload to the items * * @param eventType - The type of event whose subscribed events must be invoked. * @param payload - The information that must be passed to the subscribed items. * @function */ static publish(eventType: string, payload?: any): void; /** * Unsubscribes a subscription item belonging to a specific type of event. * * @example Example for unsubscribe() * Example usage - PCore.getPubSubUtils().unsubscribe("showCancelAlert","createStageCancelAlert","app/primary_1"); * // Unsubscribes the createStageCancelAlert function belonging to the event of type showCancelAlert. * @param eventType - The type of event * @param subscriptionItemName - The unique ID or name used to identify the subscription item. * @param contextName - The name of the context containing the event whose subscription item must be unsubscribed. eq., app/primary_1 * @function */ static unsubscribe(eventType: string, subscriptionItemName: string, contextName?: string): void; /** * Unsubscribes all subscription items belonging to a specific type of event. * * @private * @param eventType - The type of event */ static unsubscribeAllWithEventType(eventType: string): void; /** * Deletes the subscription items of all events under the given context. * * @example Example for cleanContextSubscribers() * Example usage - PCore.getPubSubUtils().cleanContextSubscribers("app/primary_1"); * // Clears all the subscription-item of all the event which fall under app/primary_1 * @param contextName - The name of the context containing the events whose subscription items must be deleted. eq., app/primary_1 * @function */ static cleanContextSubscribers(contextName: string): void; } export default PubSubUtils;