import type { DeviceChannel } from "./types.js"; /** Options for configuring polling-based subscriptions. */ export interface SubscriptionOptions { /** Polling interval in milliseconds (default 10000 = 10 seconds). */ intervalMs?: number; } /** A snapshot of a single channel's current state, emitted on change. */ export interface ChannelUpdate { serial: string; channel: number; value: number | null; units: string | null; status: string | null; timestamp: string | null; } /** Handle returned by subscribe() to stop receiving updates. */ export interface Subscription { /** Stop polling and release resources. */ unsubscribe(): void; } /** Callback invoked with each channel update. */ export type ChannelUpdateCallback = (update: ChannelUpdate) => void; /** Callback invoked when a polling cycle encounters an error. */ export type ErrorCallback = (error: Error) => void; /** Dependency: a function that fetches all channels for a device serial. */ export type ChannelFetcher = (serial: string, signal?: AbortSignal) => Promise; /** * Create a polling subscription that monitors a device's channels for changes. * * @param serial - Device serial to monitor * @param fetchChannels - Function to retrieve current channel state (injected for testability) * @param callback - Called with each channel update when state changes * @param options - Polling configuration and error handler * @returns Subscription handle with unsubscribe() */ export declare function createSubscription(serial: string, fetchChannels: ChannelFetcher, callback: ChannelUpdateCallback, options?: SubscriptionOptions & { onError?: ErrorCallback; }): Subscription; //# sourceMappingURL=subscribe.d.ts.map