ukogi
v0.0.2
Published
A wrapper for Electron IPC for both main and renderer processes
Downloads
1
Readme
ukogi
A wrapper for Electron IPC for both main and renderer processes.
Functions
on(channel, callback)
Register a handler for an IPC channel
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| channel | string | Name of the channel |
| callback | function | Callback to run when a message is received on this channel, called with arguments (event, arg, reply). Arguments passed to reply(arg) will be received by the callback in the corresponding ukogi.send
call. |
Example
ukogi.on("my-channel", (event, arg, reply) => {
if (arg.flag) reply(42);
});
send(channel, arg, callback)
Send a message through an IPC channel and receive the response
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| channel | string | Name of the channel |
| arg | * | Argument to pass |
| callback | function | Callback to run when a reply is received on this channel, called with arguments (event, arg). Arguments passed to the corresponding ukogi.on
call's reply(arg) will be received here. |
Example
ukogi.send("my-channel", { flag: true }, (event, arg) => console.log(arg)); // -> 42
License
MIT License