1.2.0 • Published 4 years ago

rx-ipc v1.2.0

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

RxJS Utility for Electron IPC

Modules

Proxy Observables

Create an Observable in one process, and remotely observe it from another.

In Renderer Process

import "rx-ipc/add/operator/proxify";
import { of } from "rxjs/observable/of";
import { v4 as uuid } from "node-uuid";
import { ipcRenderer as ipc } from "electron";

const channel = "some-identifier";
const proxiedEvents = of("foo").proxify({ ipc, channel, uuid });

proxiedEvents.subscribe(({ observer, payload }) => {
  // maps to a "proxy report"
  // `observer` = "next"; `payload` = "foo"
  console.log(`Routed { ${payload} } to { ${observer} } callback in main`);
});

In Main Process

/** In Main Process */
import { createProxy } from "rx-ipc";
import { ipcMain as ipc } from "electron";

const channel = "some-identifier"; // must match the channel of renderer
createProxy({ channel, ipc, uuid }).subscribe((payload) => {
  // Will receive "payload" (from the report above)
  // `payload` = "foo"
  console.log(`Message From Renderer: ${message}`);
});

Note: You could swap the MainProcess and RendererProcess code snippets above, and it would still work

TODO

  1. Upgrade to RxJS v6. At the moment, I'm consuming this in an app that requires RxJS v5.
1.2.0

4 years ago

1.0.1

4 years ago

1.0.0-beta.1

4 years ago

1.0.0-beta.0

4 years ago

1.0.0

4 years ago