Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

talkman

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

talkman

A simple, lightweight and flexible communication API. Define your own mechanism to send/receive your messages and leave the rest to us

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
2
Weekly downloads
 
Created
Source

talkman

A simple, lightweight and flexible communication API. Define your own mechanism to send/receive your messages and leave the rest to us (to be continued...)

sample code

import CommAPI, {TransportBrowserWindow} from 'talkman';

let source = window;         // iframe window
let target = window.parent   // parent of iframe window

const transport = new TransportBrowserWindow ({
  sourceWindow : source,
  targetWindow : target
});

const incomingInfo = (payload) => {

  console.log (payload);
  //further process "INFO" payload here
};

const incomingRequest = (payload) => {

  let res = {};
  
  try {
    // process "REQUEST" payload here
    res = {/* prepare "RESPONSE" here */};
    return res;  // resolves the awaiting request promise on the other end
  }
  catch (err) {
    throw err;  
    // rejects the awaiting request promise on the other end
  }
};

const messenger = new CommAPI ({
  transportInstance: transport,
  onReq: incomingRequest,
  onInfo: incomingInfo
});



const info = {/* INFO payload message */};
messenger.sendInfo (info);

const req = {/* REQUEST payload message */};
messenger.sendReq (req).then (
  (response) => {
    // REQUEST resolved with RESPONSE
  },
  (err) => {
    //REQUEST rejected with an error
  }
)

Keywords

FAQs

Package last updated on 08 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc