0.0.1 • Published 9 months ago

@infinex/iframe-ipc v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

@infinex/iframe-ipc

Enable simple IPC between a window and an iframe

Usage

iframe

import { IFrameIPCChild } from "@infinex/iframe-ipc";

new IFrameIPCChild({
  hello({ name }) => {
    return `Hello, ${name}!`;
  }
});

parent

import { IFrameIPCParent } from "@infinex/iframe-ipc";

const iframe = document.querySelector("iframe");
const { call } = new IFrameIPCParent(iframe, "my-website.com:443");

(async () => {
  const result = await call("hello", { name: "friend" });
  console.log(result);
})();