Interface TransportOptions

Base transport options.

interface TransportOptions {
    connectedWindow?: Window;
    expectedOrigin?: string;
    id: string;
}

Properties

connectedWindow?: Window

Attached window. Used for connecting to any window or iframe.

import {Provider} from 'magic-transport'

const id = 'UNIQ_ID'
const childOrigin = '*'
const sharedObject = {
hello: {
from: {
provider: function () {
return 'hello from provider'
}
}
}
}

const iframe = document.createElement('iframe')
iframe.src = 'https://site.app/embed'
document.body.appendChild(iframe)

const transport = new Provider({
id,
childOrigin,
connectedWindow: iframe.contentWindow,
...sharedObject
});
expectedOrigin?: string

Origin of the attached window.

id: string

Unique transport identifier. Must be the same for Provider and Consumer that communicate with each other.

Generated using TypeDoc