How to use the iframe-coordinator/client.Client function in iframe-coordinator

To help you get started, we’ve selected a few iframe-coordinator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github purecloudlabs / iframe-coordinator / demo-app / src / component.js View on Github external
// Load polyfills required for IE11
import "@babel/polyfill";
import "custom-event-polyfill/polyfill.js";
import "url-polyfill";

import { Client } from "iframe-coordinator/client";

document.getElementById("path").innerHTML = window.location.hash;

window.onhashchange = function() {
  document.getElementById("path").innerHTML = window.location.hash;
};

// Start intercepting link click events for routing
let iframeClient = new Client();
iframeClient.addListener("environmentalData", envData => {
  document.getElementById("client-data").value = JSON.stringify(envData);
});

iframeClient.messaging.addListener("host.topic", publication => {
  console.log("Got Publish event:", publication);
});

iframeClient.start();

document.getElementById("do-publish").addEventListener("click", () => {
  //Get the topic and the data to publish from the form
  let topic = document.getElementById("pub-topic").value;
  let data = JSON.parse(document.getElementById("pub-data").value);

  //Publish the data

iframe-coordinator

Tools for coordinating embedded apps via iframes.

MIT
Latest version published 2 months ago

Package Health Score

76 / 100
Full package analysis

Similar packages