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

promise-tron

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-tron

PromiseTron is a promise based communication system which simplify data exchange between electron main and renderer processes

  • 10.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Promise tron

PromiseTron is a promise based communication system library which simplify data exchange between electron main and renderer processes.

PromiseTron includes typescript definitions.

Api doc: https://thomaschampagne.github.io/promise-tron/

Install

npm install promise-tron --save

or

git clone https://github.com/thomaschampagne/promise-tron
cd promise-tron
npm install
npm run build

Usage

Message from ipcRenderer to ipcMain


import { BrowserWindow, ipcMain, ipcRenderer } from "electron";
import { PromiseTron } from "promise-tron";

// Renderer
const promiseTronRenderer = new PromiseTron(ipcRenderer);
promiseTronRenderer.send('Hi from renderer!').then(response => {
  console.log(response); // Prints: "Reply from ipcMain"
}, error => {
  console.error(error);
});

// Main
const browserWindow = new BrowserWindow();
const promiseTronMain = new PromiseTron(ipcMain, browserWindow.webContents);
promiseTronMain.on((request /*IpcRequest*/, replyWith /*(promiseTronReply: PromiseTronReply) => void*/) => {
  console.log(request.data); // Prints: "Hi from renderer!"
  replyWith({
    success: 'Reply from ipcMain',
    error: null
  });
});

Message from ipcMain to ipcRenderer

import { BrowserWindow, ipcMain, ipcRenderer } from 'electron'
import { PromiseTron } from 'promise-tron'

// Main
const browserWindow = new BrowserWindow();
const promiseTronMain = new PromiseTron(ipcMain, browserWindow.webContents);
promiseTronMain.send('Hi from main!').then(response => {
  console.log(response); // Prints: "Reply from ipcRenderer"
}, error => {
  console.error(error);
});


// Renderer
const promiseTronRenderer = new PromiseTron(ipcRenderer);
promiseTronRenderer.on((request /*IpcRequest*/, replyWith /*(promiseTronReply: PromiseTronReply) => void*/) => {
  console.log(request.data); // Prints: "Hi from main!"
  replyWith({
    success: 'Reply from ipcRenderer',
    error: null
  });
});

NPM scripts

  • npm test: Run test suite
  • npm start: Run npm run build in watch mode
  • npm run test:watch: Run test suite in interactive watch mode
  • npm run test:prod: Run linting and generate coverage
  • npm run build: Generate bundles and typings, create docs
  • npm run lint: Lints code
  • npm run commit: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)

Keywords

FAQs

Package last updated on 30 Aug 2020

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