@opalkelly/frontpanel-platform-api
Version:
TypeScript definitions for Opal Kelly FrontPanel Platform API
43 lines (36 loc) • 1.54 kB
text/typescript
/**
* Copyright (c) 2024 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 IFrontPanel from "./IFrontPanel";
import { IEventSubscription } from "./IEventSubscription";
/**
* Type representing a FrontPanel event handler.
* @param sender - The sender of the event.
*/
export type FrontPanelEventHandler = (sender: IFrontPanel) => void;
/**
* Type representing an asynchronous FrontPanel event handler.
* @param sender - The sender of the event.
* @returns {Promise<void>} - A promise that resolves when the event handling is complete.
*/
export type FrontPanelEventAsyncHandler = (sender: IFrontPanel) => Promise<void>;
/**
* Interface representing a FrontPanel event.
*/
export interface IFrontPanelEvent {
/**
* 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: FrontPanelEventHandler): 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: FrontPanelEventAsyncHandler): IEventSubscription;
}