1.3.2 • Published 4 years ago

electron-api-ipc v1.3.2

Weekly downloads
24
License
-
Repository
github
Last release
4 years ago

Electron-api-ipc

styled with prettier Travis Coveralls dependencies Status devDependencies Status peerDependencies Status

A set of decorators and a inversifyJS wrapper to manage ipc event on the main process, the same way you would manage nestjs http routes.

check the doc

Installation

npm i electron-api-ipc

yarn add electron-api-ipc

Getting started

main process

import { bootstrapIpcApi, IpcController, IpcEvent } from 'electron-api-ipc';
import { injectable, inject } from 'inversify';

@injectable()
class MyDummyService {
  doSomething() {
    console.log('i am useless');
  }
}

const $$dummy = Symbol('dummy-service');

@IpcController('test')
class MyCtrl {
  constructor(@inject($$dummy) dummyService) {
    this.dummy = dummyService;
  }

  @IpcEvent('foo')
  handleFoo(event, data) {
    console.log(data); // print hello world
    this.dummy.doSomething();
  }

  @IpcEvent('once-event', { once: true })
  handleOnce() {
    console.log('you will see me only once :(');
  }
}

const app = bootstrapIpcApi({
  controllers: [MyCtrl],
  services: [{ provide: $$dummy, useClass: MyDummyService }]
});

app.listen();

renderer process

import { ipcRenderer } from 'electron';

ipcRenderer.send('test-foo', 'hello world');

ipcRenderer.send('once-event');
ipcRenderer.send('once-event'); // nothing happen
1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago