Skip to content
browser-tab-ipc / 0.3.0-rc

browser-tab-ipc 0.3.0-rc

Install from the command line:
Learn more about npm packages
$ npm install @lopatnov/browser-tab-ipc@0.3.0-rc
Install via package.json:
"@lopatnov/browser-tab-ipc": "0.3.0-rc"

About this version

@lopatnov/browser-tab-ipc Twitter LinkedIn

npm NPM version License GitHub issues GitHub forks GitHub stars GitHub top language

Build and Test package Publish NPM package Libraries.io dependency status for latest release

With this technology, you can exchange messages between browser tabs. This is a bus network among browser tabs, inter-process communication mechanism between browser tabs. This technology allows to create a chat between browser tabs. It allows to optimize the performance of high-demand applications, decrease amount of http requests or socket connections.

Install

https://nodei.co/npm/@lopatnov/browser-tab-ipc.png?downloads=true&downloadRank=true&stars=true

npm install @lopatnov/browser-tab-ipc

Browser

<script src="https://lopatnov.github.io/browser-tab-ipc/dist/library.min.js"></script>

<!-- Example: how to use in browser -->
<script>
  //...
  ipc = new browserTabIpc.BrowserTabIPC();
  ipc.message(function (message) {
    console.log(message);
  });
  ipc
    .connect({
      sharedWorkerUri: '//lopatnov.github.io/browser-tab-ipc/dist/ipc-worker.js', // Please copy this file `dist/ipc-worker.js` to your project and replace this url
    })
    .then(function (state) {
      console.log(state);
    });
  var id = Math.trunc(Math.random() * 10000);
  setInterval(() => {
    ipc.postMessage('Hello browser Tab! I am page with ID: ' + id);
  }, 200);
  //...
</script>

Import package to the project

TypeScript

import {BrowserTabIPC} from '@lopatnov/browser-tab-ipc';

JavaScript

var library = require('@lopatnov/browser-tab-ipc');
var BrowserTabIPC = library.BrowserTabIPC;

How to use

import {BrowserTabIPC} from '@lopatnov/browser-tab-ipc';

const tabID = Math.trunc(Math.random() * 10000);
const ipc = new BrowserTabIPC();

ipc.message(function (message) {
  console.log(message);
});
const state = await ipc.connect({
  sharedWorkerUri: '//lopatnov.github.io/browser-tab-ipc/dist/ipc-worker.js', // Please copy this file `dist/ipc-worker.js` to your project and replace this url
});
console.log(state);

setInterval(() => {
  ipc.postMessage('Hello browser Tab! I am page with ID: ' + tabID);
}, 200);

Rights and Agreements

License Apache-2.0

Copyright 2022 Oleksandr Lopatnov

Details


Assets

  • browser-tab-ipc-0.3.0-rc-npm.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0