Communicating between desktop app windows.
npm install @todesktop/client-ipcCommunicating between desktop app windows.
Install @todesktop/client-ipc in your client-side application using
``sh`
npm install @todesktop/client-ipc
Installation of the plugin package is also necessary. Using ToDesktop Builder, navigate to Plugins. Click on the Explore button for "Selected Text" and install the package.
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.
`js
import { subscribe } from "@todesktop/client-ipc";
const unsubscribe = subscribe("foo", (data, context) => {
console.log({ data, context });
/**
* {
* data: { msg: "bar" },
* context: { windowId: 2, viewId: 2 }
* }
*/
});
// ...later
unsubscribe();
`
Publishes data to a messaging channel.
`js
import { publish } from "@todesktop/client-ipc";
publish("foo", { msg: "bar" });
`
Retrieves id information about the window and view.
`js
import { identify } from "@todesktop/client-ipc";
async () => {
console.log(await identify());
/**
* {
* windowId: 1,
* viewId: 1
* }
*/
};
``