npm

@onemedia/ntb-library
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

Onemedia NTB Library

Getting Started

Comprised of two integration points - Wrapper and Client. The client is intended to be instantiated within a page that will be loaded within an iframe. The wrapper needs to be instantiated on the page that loads the iframe.

Within the "child" page:

import { Client, Interface } from "@onemedia/ntb-library";

const ntbClient = new Client(window);

// Send a message up to the NTB
ntbClient.sendMessage({
  type: Interface.Onelan.actions.PLI_SET,
  params: {
    name: "EXAMPLE",
    value: newValue ? "ACCESSIBLE" : "NORMAL",
  },
});

Within the "wrapper" page:

import { Wrapper } from "@onemedia/ntb-library";

new Wrapper(window, { 
  debug: true,
  allowAllDomains: true,
  iframeUrl: './iframe.html',
  onMessageReceived: (message) => $messageLog.innerHTML += JSON.stringify(message)
});

Interfaces

All interface code sits within their own folders within the src/interface folder. They need to expose the following information:

  • actions - the individual events that can be triggered on the given NTB - for instance updating a PLI.
  • types - the Typescript type data to inform what parameters are required for each action.
  • handlers - the corresponding function that needs to be triggered when a specific action takes place.

Readme

Keywords

none

Package Sidebar

Install

npm i @onemedia/ntb-library

Weekly Downloads

2

Version

2.2.0

License

ISC

Unpacked Size

17.1 kB

Total Files

22

Last publish

Collaborators

  • alexnaish