Skip to content

2. Introduction

Dinko Miletić edited this page Jan 11, 2022 · 9 revisions

GG is component which serves for communication between parent frame and iframe. It also handles automatic iframe resize of width and height. GG provides next set of features which will be discussed later in document:

  • Automatic height and width resizing of an iframe content
  • Message exchange between frames using pub/sub pattern
  • Multiple iframe nesting
  • Event dispatching between frames
  • Allows Slave script integration with Web Worker script
  • Optional domain authentication for security

2.1. Technology

Technology used behind GG is browsers window.postMessage() api for safe cross and same origin communication.

2.2. Installation

Package can be installed via npm:

npm install @nsoft/seven-gravity-gateway --save

GG consists of 2 modules: Master and Slave module. Master module is intended for frames which will integrate 3rd party product via iframe. Slave module is intended for applications which will be integrated in some 3rd party frame.

2.3. In browser use

Modules are exposed as UMD modules which we can be required as CommonJS or AMD modules, or simply injecting the script in HTML and using the global reference.

Master gateway:

<script src="https://unpkg.com/@nsoft/seven-gravity-gateway@latest/dist/master.min.js"></script>
const Gateway = window.gravity.gateway.master;

Slave gateway:

<script src="https://unpkg.com/@nsoft/seven-gravity-gateway@latest/dist/slave.min.js"></script>
const Gateway = window.gravity.gateway.slave;

2.4. As node module

To load both modules:

import Gateway from '@nsoft/seven-gravity-gateway';

Result with be object with master and slave properties

We can load separately master or slave module by requiring:

For master:

import Gateway from '@nsoft/seven-gravity-gateway/master';
Clone this wiki locally