UNPKG

@vertigis/viewer-spec

Version:

VertiGIS Viewer Specification

27 lines (26 loc) 837 B
import type { Message } from "./Message.js"; import type { Model } from "./common.js"; /** * A callback that will be invoked whenever the event is published. */ export type EventCallback<T> = (arg?: T, publisher?: Model, eventName?: string) => void | Promise<void>; /** * A named event. */ export interface Event<T = void> extends Message { /** * Publishes the event to all subscribers. * * @returns A promise that is fulfilled once all subscribers have been * notified. */ publish: (arg: T, publisher?: Model) => Promise<void>; /** * Subscribes to this event. * * @param callback A callback that will be invoked whenever the event is * published. * @returns A handle that can be used to unsubscribe. */ subscribe: (callback: EventCallback<T>) => IHandle; }