How to use the iframe-coordinator/BackgroundClient 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 / js / demo-app / src / workers / failure-worker.js View on Github external
// This worker is designed to showcase worker error rate handling.
import BackgroundClient from "iframe-coordinator/BackgroundClient";

const client = new BackgroundClient();

let currTimeout = setTimeout(triggerError, getTimeout());

function triggerError() {
  // Setup the next error call, since the error will stop this function execution
  currTimeout = setTimeout(triggerError, getTimeout());

  console.error('Triggering an intentional error from a background worker.  Will not pop rate limit');
  foo.bar.baz();
}

// TODO - better listener from client api - with auto cleanup
addEventListener('message', evt => {
  if (evt.data.msgType === 'before_unload') {
    // Shutdown requested from host.  Clean-up and acknowledge
    if (currTimeout) {
github purecloudlabs / iframe-coordinator / js / demo-app / src / workers / demo-worker.js View on Github external
import BackgroundClient from "iframe-coordinator/BackgroundClient";
// TODO Need a better demo that makes more sense?

const client = new BackgroundClient();

// Routing example
// client.requestNavigation('/wikipedia');

let currTimeout = setTimeout(sendToastMessage, getTimeout(5000, 10000));

function sendToastMessage() {
  client.requestToast('from a Headless Worker', {
    custom: {
      level: 'info'
    },
    title: 'Hello worker World'
  });

  currTimeout = setTimeout(sendToastMessage, getTimeout());
}

iframe-coordinator

Tools for coordinating embedded apps via iframes.

MIT
Latest version published 10 days ago

Package Health Score

73 / 100
Full package analysis

Similar packages