@wuchuheng/window-message
Version:
A modern TypeScript library for cross-window messaging
13 lines (11 loc) • 433 B
text/typescript
type CreateChannelReturn<Req, Res> = {
request: (message: Req, windowObj: Window) => Promise<Res>;
handle: (callback: (req: Req) => Promise<Res>) => void;
};
/**
* Create a channel to communicate with the window.
* @param channel - The channel to create.
* @returns The request and handle functions.
*/
declare const createChannel: <Req, Res>(channel: string) => CreateChannelReturn<Req, Res>;
export { createChannel };