1.0.13 • Published 4 years ago

frame-request v1.0.13

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

FrameRequest

Description

A Typescript/Javascript library for iframe requests/responses

Getting Started

Installing

npm i frame-request

Usage

In your parent window javascript file simply put:

import { FrameRequest } from "frame-request";

const channel = new FrameRequest(
    "Some Channel Name", 
    {}, 
    "my-iframe-selector"
);

channel
.request("helloRequest", { myData: "hello" })
.then(res => {
    console.log(res); // { world: 'world' }
});

In your iframe's javascript file put:

import { FrameRequest } from "frame-request";

const channel = new FrameRequest("Some Channel Name", {
    // define what to do with requests
    helloRequest: ({ payload, reply }) => {
        console.log(payload); // {myData: 'hello'}
        reply({
            world: "world"
        });
    }
});

Authors

Guy Golan - @GuyGolan

Version History

  • 1.0.13 throwing error if channel name was not provided
  • 1.0.12 fixed README.md
  • 1.0.11 added README.md and refactored name to FrameRequest
  • 1.0.10
1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago