import { Unsubscribable, Observable } from 'rxjs'; /** * @alpha * internal interface */ export interface BusEvent { readonly type: string; readonly payload?: any; origin?: EventBus; } /** * @alpha * Base event type */ export declare abstract class BusEventBase implements BusEvent { readonly type: string; readonly payload?: any; readonly origin?: EventBus; /** @internal */ tags?: Set; constructor(); /** * @internal * Tag event for finer-grained filtering in subscribers */ setTags(tags: string[]): this; } /** * @alpha * Base event type with payload */ export declare abstract class BusEventWithPayload extends BusEventBase { readonly payload: T; constructor(payload: T); } export interface BusEventType { type: string; new (...args: any[]): T; } /** * @alpha * Event callback/handler type */ export interface BusEventHandler { (event: T): void; } /** * @alpha * Main minimal interface */ export interface EventFilterOptions { onlyLocal: boolean; } /** * @alpha * Main minimal interface */ export interface EventBus { /** * Publish single event */ publish(event: T): void; /** * Get observable of events */ getStream(eventType: BusEventType): Observable; /** * Subscribe to an event stream * * This function is a wrapper around the `getStream(...)` function */ subscribe(eventType: BusEventType, handler: BusEventHandler): Unsubscribable; /** * Remove all event subscriptions */ removeAllListeners(): void; /** * Returns a new bus scoped that knows where it exists in a heiarchy * * @internal -- This is included for internal use only should not be used directly */ newScopedBus(key: string, filter: EventFilterOptions): EventBus; } /** * @public * @deprecated event type */ export interface AppEvent { readonly name: string; payload?: T; } /** @public */ export interface LegacyEmitter { /** * @deprecated use $emit */ emit(event: AppEvent | string, payload?: T): void; /** * @deprecated use $on */ on(event: AppEvent | string, handler: LegacyEventHandler): void; /** * @deprecated use $on */ off(event: AppEvent | string, handler: LegacyEventHandler): void; } /** @public */ export interface LegacyEventHandler { (payload?: T): void; wrapper?: (event: BusEvent) => void; } /** @alpha */ export interface EventBusExtended extends EventBus, LegacyEmitter { }