@mescius/dsimageviewer
Version:
Document Solutions Image Viewer
82 lines (81 loc) • 2.87 kB
TypeScript
import { IEventBus } from "../Models/IImageViewer";
/**
* Event handler attach options.
**/
export declare type EventBusAttachOptions = {
/**
* @ignore exclude from docs: all user events are external.
**/
external?: boolean;
/**
* Listen to the event once.
**/
once?: boolean;
};
/**
* EventBus event name.
* @example
* ```javascript
* viewer.eventBus.on("zoom-changed", function(args) {
* console.log("Zoom changed", args);
* });
* ```
**/
export declare type EventBusEventName = "before-open" | "after-open" | "before-close" | "after-close" | "zoom-changed" | "frame-index-changed" | "animation-started" | "animation-stopped" | "keydown" | "keyup" | "object-designer-bounds-changed";
/**
* The image viewer event bus.
* @description
* Use the event bus to listen and receive certain specific "events".
* Available events are: "before-open", "after-open", "before-close", "after-close", "zoom-changed", "frame-index-changed", "animation-started", "animation-stopped".
* @example
* ```javascript
* // Liisten frame index changes:
* viewer.eventBus.on("frame-index-changed", function(args) { console.log("Image frame changed", args); });
* ```
* @example
* ```javascript
* // Listen "after-open" event once:
* viewer.eventBus.on("after-open", function(args) { console.log("Image opened", args); }, { once: true });
* ```
**/
export declare class EventBus implements IEventBus {
private _listeners;
/**
* Class constructor.
**/
constructor();
/**
* Listen eventbus event.
* @param {string} eventName
* @param {function} listener
* @param {Object} [options]
*/
on(eventName: EventBusEventName, listener: any, options?: EventBusAttachOptions): void;
/**
* Remove event listener specified by the listener argument for the event specified by the eventName argument.
* @param {string} eventName
* @param {function} listener
*/
off(eventName: EventBusEventName, listener: any): void;
/**
* Remove all event listeners for the event specified by the eventName argument.
* @param {string} eventName
*/
offAll(eventName: EventBusEventName): void;
/**
* Use the dispatch method to raise an event.
* @param {string} eventName
* @param {Object} data
*/
dispatch(eventName: EventBusEventName, data: any): void;
/**
* Internal listen implementation, takes priority over public "on" API.
* @ignore
*/
_on(eventName: EventBusEventName, listener: any, options?: EventBusAttachOptions): void;
/**
* Internal unlisten implementation, takes priority over public "off" API.
* @ignore
**/
_off(eventName: EventBusEventName, listener: Function | false): void;
}