Class Consumer<P, C>

Transport used on the page loaded inside an iframe. Inherits the interface EventEmitter.

import {Consumer} from 'magic-transport'

const id = 'UNIQ_ID'
const parentOrigin = '*'
const sharedObject = {
hello: {
from: {
consumer() {
return transport.provider.hello.from.provider()
}
}
},
timeout(callback, timeout) {
setTimeout(() => {
callback('hello from consumer')
}, timeout)
}
}

const transport = new Consumer({id, parentOrigin, ...sharedObject})

transport.once('ready', () => {
// Transport is ready to use
})

Type Parameters

  • P

    The provider facade.

  • C

    The consumer facade.

Hierarchy (view full)

Constructors

Constructors

Generated using TypeDoc