How to use the penpal.connectToParent function in penpal

To help you get started, we’ve selected a few penpal 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 Aaronius / penpal / types / type-tests.ts View on Github external
/**
 * Child Frame (flexible)
 */
const flexibleChildConnection = Penpal.connectToParent({
  // Methods child is exposing to parent
  methods: childMethods
});

flexibleChildConnection.promise.then(parent => {
  parent.add(3, 1); // $ExpectType any
});
/**
 * Child Frame (strict)
 */
const strictChildConnection = Penpal.connectToParent({
  // Methods child is exposing to parent
  methods: childMethods
});

strictChildConnection.promise.then(parent => {
  parent.add(3, 1).then(total => {
    total; // $ExpectType number
  });
});
github Aaronius / penpal / types / type-tests.ts View on Github external
});

strictParentConnection.promise.then(child => {
  child.multiply(2, 6).then(total => {
    total; // $ExpectType number
  });
  child.divide(12, 4).then(total => {
    total; // $ExpectType number
  });
  child.foo(12, 4); // $ExpectError
});

/**
 * Child Frame (flexible)
 */
const flexibleChildConnection = Penpal.connectToParent({
  // Methods child is exposing to parent
  methods: childMethods
});

flexibleChildConnection.promise.then(parent => {
  parent.add(3, 1); // $ExpectType any
});
/**
 * Child Frame (strict)
 */
const strictChildConnection = Penpal.connectToParent({
  // Methods child is exposing to parent
  methods: childMethods
});

strictChildConnection.promise.then(parent => {
github weseek / growi / src / client / js / hackmd-agent.js View on Github external
function connectToParentWithPenpal() {
  const connection = Penpal.connectToParent({
    parentOrigin: allowedOrigin,
    // Methods child is exposing to parent
    methods: {
      getValue() {
        return getValueOfCodemirror();
      },
      setValue(newValue) {
        setValueToCodemirror(newValue);
      },
      setValueOnInit(newValue) {
        setValueToCodemirrorOnInit(newValue);
      }
    }
  });
  connection.promise.then(parent => {
    window.growi = parent;
github weseek / growi / src / client / js / hackmd-agent.js View on Github external
function connectToParentWithPenpal() {
  const connection = Penpal.connectToParent({
    parentOrigin: allowedOrigin,
    // Methods child is exposing to parent
    methods: {
      getValue() {
        return getValueOfCodemirror();
      },
      setValue(newValue) {
        setValueToCodemirror(newValue);
      },
      setValueOnInit(newValue) {
        setValueToCodemirrorOnInit(newValue);
      },
    },
  });
  connection.promise.then((parent) => {
    window.growi = parent;

penpal

A promise-based library for communicating with iframes via postMessage.

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis