Files
IdeA/frontend/src/adapters/pluginEvents.ts

28 lines
882 B
TypeScript

/**
* Tauri adapter for stable public plugin events (#127).
*/
import { invoke } from "@tauri-apps/api/core";
import type { PluginEventBatch, PluginEventSubscription } from "@/domain";
import type {
PluginEventGateway,
PluginEventPollInput,
PluginEventSubscribeInput,
PluginEventUnsubscribeInput,
} from "@/ports";
export class TauriPluginEventGateway implements PluginEventGateway {
subscribe(input: PluginEventSubscribeInput): Promise<PluginEventSubscription> {
return invoke<PluginEventSubscription>("plugin_events_subscribe", { input });
}
poll(input: PluginEventPollInput): Promise<PluginEventBatch> {
return invoke<PluginEventBatch>("plugin_events_poll", { input });
}
unsubscribe(input: PluginEventUnsubscribeInput): Promise<PluginEventSubscription> {
return invoke<PluginEventSubscription>("plugin_events_unsubscribe", { input });
}
}