@devexperts/dxcharts-lite
Version:
49 lines (48 loc) • 2 kB
TypeScript
/*
* Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { Observable } from 'rxjs';
import { EVENT_DRAW, EVENT_RESIZED } from './events';
export interface EventBusFireAsync {
(type: typeof EVENT_RESIZED, event?: ClientRect | DOMRect): number | void;
(type: string, event?: string): number | void;
(type: string, event?: string): number | void;
}
export interface EventBusFire {
(type: typeof EVENT_RESIZED, event?: ClientRect | DOMRect): number | void;
(type: string, ...args: unknown[]): void;
}
export interface EventBusOn {
(type: typeof EVENT_RESIZED, fn: (bcr?: DOMRect) => void): () => void;
(type: typeof EVENT_DRAW, fn: (canvasIds: Array<string>) => void): () => void;
(type: string, fn: (...args: unknown[]) => void): () => void;
}
/**
* Event bus for chart.
* @doc-tags core-components
*/
export default class EventBus {
private UNKNOWN_ARR;
/** Registered event handlers. */
private handlers;
/** State which can enable / disable events processing. */
private muted;
constructor();
/**
* Triggers the draw event for the specified canvas IDs.
* @param {Array<string>} canvasIds - An optional array of canvas IDs to trigger the draw event for.
*/
fireDraw(canvasIds?: Array<string>): void;
unsub: (type: string, fn: (...args: any[]) => void) => void;
add: (method: (...args: unknown[]) => void, type: string, fn: (...args: any[]) => void) => () => void;
on: EventBusOn;
observe: (type: string) => Observable<any>;
onPrior: (type: string, fn: (...args: any[]) => void) => () => void;
off: (type: string, fn: (...args: any[]) => void) => void;
fire: EventBusFire;
fireAsync: EventBusFireAsync;
setMuted: (val: boolean) => void;
clear: () => void;
}