import type { ResourceHandle } from "@arcgis/core/core/Handles"; 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 = (arg?: T, publisher?: Model, eventName?: string) => void | Promise; /** * A named event. */ export interface Event 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; /** * 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) => ResourceHandle; }