UNPKG

@kvaser/canking-api

Version:

CanKing API to communicate with the CanKing service using Node.js.

29 lines (28 loc) 1.64 kB
/** * Possible CanKing event channels for an extension to listen to. */ export type extensionEventChannels = 'devices-changed' | 'new-log-messages' | 'online-status-changed' | 'periodic-trans-started' | 'periodic-trans-stopped' | 'new-measurement-data' | 'new-measurement-status' | 'user-settings-changed' | 'meas-setup-changed' | 'workspace-panes-changed'; /** * Starts a subscription to an event raised by CanKing. * * @typeParam T - Type of the data that will be sent by the event. * @param key - A unique key for this subscription, this key should be used when calling removeEventListener to unsubcribe * from the event. The uuid package can be used for generating unique keys. * @param event - The event channel to subscibe to. * @param callback - A callback that will be called when new data arrives on the channel. * @param options - Optional options including following options: * numberOfHistoryFrames - used when adding a 'new-measurement-data' event listener to control number of frames to read from history at initialization. * @returns A promise that will resolve with start values for the event. * @internal */ export declare function addEventListener<T>(key: string, event: extensionEventChannels, callback: (data: T) => void, options?: { numberOfHistoryFrames?: number; }): Promise<T>; /** * Unsubscribes from an event. * * @param key - The key that was used when addEventListener was called. * @param event - The event channel to unsubscribe from. * @internal */ export declare const removeEventListener: (key: string, event: extensionEventChannels) => Promise<void>;