import { type CancellationToken, Event, Relay } from "./foundation.js"; import type { IChannel } from "./channels.shared.js"; export function getDelayedChannel(promise: Promise): T { return { call(command: string, arg?: any, cancellationToken?: CancellationToken): Promise { return promise.then((channel) => channel.call(command, arg, cancellationToken)); }, listen(event: string, arg?: any): Event { const relay = new Relay(); promise.then((channel) => { relay.input = channel.listen(event, arg); }); return relay.event; }, } as T; }