UNPKG

@opalkelly/frontpanel-platform-api

Version:

TypeScript definitions for Opal Kelly FrontPanel Platform API

48 lines (41 loc) 1.69 kB
/** * Copyright (c) 2025 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ import IDeviceManager from "./IDeviceManager"; import { IEventSubscription } from "./IEventSubscription"; /** * Type representing a Device event handler. * @param sender - The sender of the event. * @param serialNumber - The serial number of the device. */ export type DeviceEventHandler = (sender: IDeviceManager, serialNumber: string) => void; /** * Type representing an asynchronous Device event handler. * @param sender - The sender of the event. * @param serialNumber - The serial number of the device. * @returns {Promise<void>} - A promise that resolves when the event handling is complete. */ export type DeviceEventAsyncHandler = ( sender: IDeviceManager, serialNumber: string ) => Promise<void>; /** * Interface representing a Device event. */ export interface IDeviceEvent { /** * Subscribes a handler to the event. * @param handler - The handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribe(handler: DeviceEventHandler): IEventSubscription; /** * Subscribes an asynchronous handler to the event. * @param handler - The asynchronous handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribeAsync(handler: DeviceEventAsyncHandler): IEventSubscription; }