@onirix/embed-sdk

1.5.1 • Public • Published

Onirix Embed SDK

This library acts as a wrapper of window.postMessage for simplifying communication with Onirix iframes.

Full documentation available at Onirix Docs.

Usage

Using a bundler (Webpack, Rollup):

  1. Install the dependency:
npm install @onirix/embed-sdk
  1. Import and use it within your code:
const iframeElement = document.getElementById("<iframe_element_id>");
const embedSDK = new OnirixEmbedSDK(iframeElement);

embedSDK.connect().then(() => {

    // Ready to subscribe to events and/or execute actions

});

Using plain HTML

  1. Include the dependency within the HTML head tag:
<head>
...
    <script src="https://unpkg.com/@onirix/embed-sdk@latest/dist/ox-embed-sdk.umd.js">
...
</head>
  1. Use it from any other script:
<script>

    const iframeElement = document.getElementById("<iframe_element_id>");
    const embedSDK = new OnirixEmbedSDK(iframeElement);

    embedSDK.connect().then(() => {

        // Ready to subscribe to events and/or execute actions

    });

</script>
  1. As ESM modules:
import OnirixEmbedSDK from "https://unpkg.com/@onirix/embed-sdk@latest/dist/ox-embed-sdk.umd.js";
const embedSDK = new OnirixEmbedSDK();
await embedSDK.connect();

embedSDK.subscribe(OnirixEmbedSDK.Events.ELEMENT_CLICK, (params) => {
    console.log('somebodey clicks me!', params);
});

Readme

Keywords

none

Package Sidebar

Install

Weekly Downloads

324

Version

1.5.1

License

Propietary

Unpacked Size

33.4 kB

Total Files

7

Last publish

Collaborators

  • onirix