0.0.12 • Published 10 months ago

@funtech-inc/handshake v0.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Promise-based postMessage iframe communication library. 0 dependencies, Lightweight.

$ npm i @funtech-inc/handshake --D
// CDN
<script src="https://unpkg.com/@funtech-inc/handshake@latest">

Example

parent

new Handshake.Parent({
   container: "container",
   url: "http://example.com/child",
}).ready(({ on, emit, container, iframe }) => {
   console.log(container); // HTMLElement
   console.log(iframe); // HTMLIFrameElement
   emit("parentToChild", "hello child");
   on("childToParent", (data) => {
      console.log(data);
   }); // Log... "hello parent"
});

child

new Handshake.Child().ready(({ on, emit }) => {
   emit("childToParent", "hello parent");
   on("parentToChild", (data) => {
      console.log(data);
   }); // Log... "hello child"
});

License

MIT

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago

0.0.0

10 months ago