@pirireis/application-transport
v1.0.16
Published
Send and Get messages for iframe
Downloads
6
Keywords
Readme
Application Transport
application-transport is for sending specified messages to iframe apps and getting from iframe apps.
How to add dependency
yarn add @pirireis/application-transport
How to use
sending messages from parent app:
const transport = new Transport({iframeId: '', applicationId: ''});
transport.sendMessage(EventTypes.POINT, coordinates);
iframeId is the id of the iframe that used. applicationId is the constant id of the child application.
There are three EventTypes:
POINT, POLYLINE, POLYGON
coordinates format example for POINT:
[35.12, 42.10]
getting messages from child application:
const transport = new Transport({applicationId: ''});
transport.on(EventTypes.POINT, (data) => { });
removing eventListener:
this should be in componentWillUnmount lifecycle:
const transport = new Transport({applicationId: ''});
transport.removeListener();