@eclipse-scout/core
Version:
Eclipse Scout runtime
50 lines • 2.86 kB
TypeScript
/// <reference types="jquery" />
import { UiNotificationHandler, UiNotificationSystem } from '../index';
export declare class UiNotifications {
systems: Map<string, UiNotificationSystem>;
/**
* Subscribes for a specific topic and executes the given handler whenever a notification for that topic arrives.
*
* The same topic can be subscribed multiple times by different handlers.
* The first subscription establishes the connection.
*
* @param topic Can be any string.
* Try to make the topic as specific as possible, e.g. by appending the id of an element to the topic name, instead of filtering the notifications in the UI.
* This reduces the overhead of sending unnecessary notifications to clients.
* @param system The system that publishes the notification. If no system is provided, the `main` system is used, which points to `api/ui-notifications`.
* To subscribe to a system with different url, the system must be registered first using {@link systems.getOrCreate} and then calling {@link System.setBaseUrl}
* and/or {@link System.setEndpointUrl}.
* @returns a promise that will be resolved as soon as the subscription was successful and notifications can be received.
*/
subscribe(topic: string, handler: UiNotificationHandler, system?: string): JQuery.Promise<string>;
/**
* Subscribes for a specific topic and executes the given handler when the first notification for that topic arrives.
* After that, the handler will automatically be unsubscribed.
*
* @see subscribe
*/
subscribeOne(topic: string, handler: UiNotificationHandler, system?: string): JQuery.Promise<string>;
/**
* Unsubscribes the handler from a specific topic, so it won't be called anymore when a notification for that topic is published.
*
* If the last handler was removed for the given system, the connection will be closed and not opened again until a new topic will be subscribed.
*/
unsubscribe(topic: string, handler?: UiNotificationHandler, system?: string): void;
/**
* Unregisters the system and closes the pending connection, if there is any.
*/
unregisterSystem(name: string): void;
/**
* Computes a reload delay for the current client which lies within the given time window.
* @param reloadDelayWindow The time window in which the random delay must be (maximum) in seconds.
* @returns The delay in milliseconds.
*/
computeReloadDelay(reloadDelayWindow: number): number;
/**
* Unregisters all systems and closes the pending connections, if there are any.
*/
tearDown(): void;
protected _getOrInitSystem(system?: string): UiNotificationSystem;
}
export declare const uiNotifications: UiNotifications;
//# sourceMappingURL=uiNotifications.d.ts.map