ToDesktop Client IPC
This is the repo for the ToDesktop IPC client.
This is a zero-dependency package for interacting with @todesktop/plugin-ipc. This package exposes a set of functions for communicating between windows.
Installation
Install @todesktop/client-ipc
in your client-side application using
$ npm install @todesktop/client-ipc
Installation of the plugin package is also necessary.
Usage
subscribe
Subscribes to a messaging channel and executes a callback when that message is triggered. The callback contains the data
and context
information from the sender.
You can also unsubscribe
from a messaging channel by executing the function that is returned from the initial subscribe
call.
import { subscribe } from "@todesktop/client-ipc";
const unsubscribe = subscribe("foo", (data, context) => {
console.log({ data, context });
});
unsubscribe();
publish
Publishes data to a messaging channel.
import { publish } from "@todesktop/client-ipc";
publish("foo", { msg: "bar" });
identify
Retrieves id information about the window and view.
import { identify } from "@todesktop/client-ipc";
(async () => {
console.log(await identify())
})
Architecture
This package requires the following files:
src/index.ts
: exposes plugin functionality through strongly-typed, easy-to-use functions.src/generated/plugin.d.ts
: automatically generated types from @todesktop/plugin-ipc
's index.ts
file.
Development
Refer to the root repo for development instructions.