@onemedia/ntb-library
v2.2.0
Published
NTB wrapper and application utilities
Downloads
14
Readme
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.