Options
All
  • Public
  • Public/Protected
  • All
Menu

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

author

Thomas Champagne

licence

MIT

Hierarchy

  • PromiseTron

Index

Constructors

constructor

  • new PromiseTron(ipc: IpcMain | IpcRenderer, webContents?: Electron.WebContents): PromiseTron
  • Instantiate PromiseTron

    Parameters

    • ipc: IpcMain | IpcRenderer

      Pass IpcMain or IpcRenderer

    • Optional webContents: Electron.WebContents

      Pass the webContents object of your BrowserWindow if you're on main thread

    Returns PromiseTron

Properties

ipcMain

ipcMain: IpcMain

ipcRenderer

ipcRenderer: IpcRenderer

isMain

isMain: boolean

isRenderer

isRenderer: boolean

logger

logger: any

webContents

webContents: WebContents | null

Static REQUEST_FROM_MAIN

REQUEST_FROM_MAIN: string = "promise-tron-request-from-main"

Static REQUEST_FROM_RENDERER

REQUEST_FROM_RENDERER: string = "promise-tron-request-from-renderer"

Static RESPONSE_TO_MAIN

RESPONSE_TO_MAIN: string = "promise-tron-response-to-main"

Static RESPONSE_TO_RENDERER

RESPONSE_TO_RENDERER: string = "promise-tron-response-to-renderer"

Methods

on

  • on(onRequest: function): void
  • Listen for {IpcRequest} from main thread if on a renderer thread Listen for {IpcRequest} from renderer thread if on a main thread

    Parameters

    • onRequest: function

      Callback which provides incoming {IpcRequest} and replyWith function

    Returns void

send

  • send(data: any): Promise<any>
  • Send data to ipcMain if called from a renderer thread Send data to ipcRenderer if called from main thread

    Parameters

    • data: any

    Returns Promise<any>

    Promise of expected result

Static genId

  • genId(length?: undefined | number): string
  • Generate a random unique identifier

    Parameters

    • Optional length: undefined | number

    Returns string

Static isProcessRenderer

  • isProcessRenderer(): boolean
  • Tells if your are running into a renderer process. If false, you are in main process

    Returns boolean

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc